简体   繁体   中英

moment.js compare dates via .diff()

Im having problems when I try to compare 2 dates.

var end = moment(items[i].dateEnd).format('DD/MM/YYYY');
var now = moment().format('DD/MM/YYYY');

Example: now = '29/10/2015' and end = '30/06/2015'

Tried using .diff() function from moment.js without any result, like this:

end.diff(now); 

Any help? Thanks.

您可以尝试指定输入日期格式:

moment(items[i].dateEnd, 'DD/MM/YYYY').diff(moment());

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