2021年1月28日星期四

JavaScript UTC Date Comparison Bug

I'm comparing UTC dates and getting this very weird result.

now is definitely bigger than start as far as I can tell, yet the statement returns false.

var start = new Date('2021-01-29T21:00:00.000Z');  var now   = new Date('2021-01-29T00:16:47.797Z');    console.log(now >= start); //false

The issue seems to be related to midnight (00), it seems to work fine for other times.

I did notice by the way that there's an existing stackoverflow issue with a pretty similar title, but the issue itself seems to be different.

https://stackoverflow.com/questions/65947371/javascript-utc-date-comparison-bug January 29, 2021 at 08:58AM

没有评论:

发表评论