我正在使用moment.js 1.7.0 尝试将今天的日期与另一个日期进行比较,但该diff
函数说由于某种原因它们相隔 1 天。
代码:
var releaseDate = moment("2012-09-25");
var now = moment(); //Today is 2012-09-25, same as releaseDate
console.log("RELEASE: " + releaseDate.format("YYYY-MM-DD"));
console.log("NOW: " + now.format("YYYY-MM-DD"));
console.log("DIFF: " + now.diff(releaseDate, 'days'));
控制台:
RELEASE: 2012-09-25
NOW: 2012-09-25
DIFF: 1
想法?