简体   繁体   中英

Date format Moment JS

Using format like this works in moment.js

function test {
    return "DD-MM-YY"
}

but changing to "DD-MM-YY" doesn't work anymore. Does anyone know why?

I'm trying to compare 2 dates:

function test {
    return "DD-MM-YY"
}

var monthMoment = moment().add(1, 'months');

var currentVal = moment($('#fromtextbox').val(), test(), true);
    if (currentVal.isAfter(monthMoment)) {
        return curentVal;
    }
    return monthMoment;

在此处输入图片说明

Do you mean like this? I test it's ok.

You can use a simple format :

var monthMoment = moment().add(1, 'months').format("DD-MM-YYYY");
var currentVal= moment($('#fromtextbox').val(), test(), true).format("DD-MM-YYYY");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM