在node.js中检查两个日期格式的时间戳

时间:2021-01-24 22:01:53

I have one date as "Wed,21 Aug 2013 12:13:50 GMT" and another as ISODate("2013-09-02T08:20.192Z").Now I have to check which time stamp is greater in node.js. How this can be possible?

我有一个日期为“Wed,2013年8月21日12:13:50 GMT”,另一个日期为ISODate(“2013-09-02T08:20.192Z”)。现在我必须检查node.js中哪个时间戳更大。这怎么可能?

1 个解决方案

#1


1  

datejs (http://www.datejs.com/) can parse the ISO Date

datejs(http://www.datejs.com/)可以解析ISO日期

var date1 = Date.parse('1997-07-16T19:20:15')

the other date is parseable by standard javascript as:

另一个日期可通过标准javascript解析为:

var date2 = new Date('Wed,21 Aug 2013 12:13:50 GMT')

then you can simply use the date1 > date2 comparison to see which is greatest

然后你可以简单地使用date1> date2比较来查看哪个最好

#1


1  

datejs (http://www.datejs.com/) can parse the ISO Date

datejs(http://www.datejs.com/)可以解析ISO日期

var date1 = Date.parse('1997-07-16T19:20:15')

the other date is parseable by standard javascript as:

另一个日期可通过标准javascript解析为:

var date2 = new Date('Wed,21 Aug 2013 12:13:50 GMT')

then you can simply use the date1 > date2 comparison to see which is greatest

然后你可以简单地使用date1> date2比较来查看哪个最好