【发布时间】:2017-07-07 17:19:12
【问题描述】:
所以我有两个日期我想了解一下:
console.log(new Date(Date.now()).toISOString()); //2017-07-07T16:55:30.471Z
console.log(asset.past[i].date); //2017-07-06T20:29:00.670Z
var a = moment([new Date(Date.now()).toISOString()]);
console.log(a); //Moment Date:Sun Jan 01 2017 00:00:00 GMT+0000
var b = moment([asset.past[i].date]);
console.log(b); //Moment Date:Sun Jan 01 2017 00:00:00 GMT+0000
console.log(a.diff(b, 'seconds', true)); //0
console.log(a.diff(b, 'days', true)); //0
console.log(a.diff(b, 'months', true)); //0
之后我将控制台日志的输出作为 cmets。我认为它无法将日期格式识别为 ISO 8601,并且默认为 Sun Jan 01 2017 00:00:00 GMT+0000。无论哪种方式,知道如何解决它吗?
干杯,埃德。
【问题讨论】:
标签: javascript node.js momentjs jsx iso8601