javascript toISOString() ignores timezone offset
https://stackoverflow.com/questions/10830357/javascript-toisostring-ignores-timezone-offset
Javascript new Date().toISOString might be different than just priniring out new Date() because it ignores timezone offset.
Solution, manually add offset
var tzoffset = (new Date()).getTimezoneOffset() * 60000; //offset in milliseconds
var localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -1);
console.log(localISOTime) // => '2015-01-26T06:40:36.181'
No comments:
Post a Comment