I get an issue while calculating time from a date string. Here is the function strtotime, as its name, would convert a standard date string to Unix timestamp.
var strtotime = (t) => {
return new Date(t).getTime();
};
From my local time (GMT+7), the result for this function is different between node.js v6.0.0 and older versions.
let s = 'Thu, 18 Feb 2016 15:28:20 GMT+07';
let t = strtotime(s);
t is equal to 1455784100000 in node.js v6.0.0 but 1455808880000 in older versions.
Issue also happens in Travis server. Here is the build info:
https://travis-ci.org/ndaidong/bella.js/builds/126068193
Anyone get the same problem? And what wrong here?
Thanks,
Dong
This seems more like a bug that鈥檚 fixed in v6 than one that鈥檚 introduced. Thu, 18 Feb 2016 15:28:20 GMT+07 corresponds to the unix timestamp 1455784100(000).
@addaleax : did you mean that the result calculated by older versions was incorrect?
@ndaidong I think so, yes. For Node.js 5.11.0:
> new Date('Thu, 18 Feb 2016 15:28:20 GMT+07').toString()
'Thu Feb 18 2016 15:21:20 GMT+0000 (UTC)'
I think what when wrong is that GMT+07 got parsed as GMT+0007, not GMT+0700, i.e. 7 minutes after GMT, not 7 hours.
@addaleax you're rock! It seems that is exactly the original cause of issue. Thank you.
Cool, closing this then. :)
Most helpful comment
Cool, closing this then. :)