0
var firstDate=moment('Sat Jul 30 2016 00:00:00 GMT+0530 (India Standard Time)');
var secondDate=moment('Fri Jul 29 2016 10:56:39 GMT+0530 (India Standard Time)');

console.log(firstDate.diff(secondDate,'days'));

预期产出:1

实际输出:-0

为什么会发生这种情况?

4

1 回答 1

1

将第二个参数传递true给 diff 方法,以防止矩将差值四舍五入到最接近的零。

firstDate.diff(secondDate,'days', true)
于 2016-07-29T05:53:45.140 回答