Issue metadata
Sign in to add a comment
|
Chrome 58.0.3029.110 version not converting date in correct local timezone
Reported by
stripat...@gmail.com,
May 22 2017
|
||||||||||||||||||||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
Steps to reproduce the problem:
1. Open developer console
2. Enter this: new Date("2017-05-22T14:00:00");
3. Output will be not incorrect local timeZone
What is the expected behavior?
I was in IST time zone and was expecting that output will be this
Mon May 22 2017 19:30:00 GMT+0530 (IST)
Converted to my local timezone. Safari is giving correct output
What went wrong?
Date not converted correctly to local timeZone.
As can see in screenshot even moment.js library is not able to give the correct value. Even restarted my machine to check.
Did this work before? Yes
Chrome version: 58.0.3029.110 Channel: stable
OS Version: OS X 10.12.4
Flash Version:
,
May 22 2017
Firefox puts the output in UTC: "Date 2017-05-22T18:00:00.000Z" As far as I can tell we are also correct because we do not put in UTC, but rather note the timezone information: "Mon May 22 2017 14:00:00 GMT-0400 (EDT)" is the same time. Leave it to someone who knows the spec better to make the call on WontFix.
,
May 22 2017
I am in IST timezone and on doing this:
new Date("2017-05-22T14:00:00");
Output is:
Mon May 22 2017 14:00:00 GMT+0530 (IST)
Here it is returning the same DateTime rather it should give output as:
Mon May 22 2017 19:30:00 GMT+0530 (IST)
Found that if instead of this:
new Date("2017-05-22T14:00:00");
I use this:
new Date("2017-05-22T14:00:00Z");
It gives correct output. It was working before, recent update changed the output.
,
May 22 2017
No, it should not do any conversions on input. And you are just witnessing the debug output being .toISOString() instead of .toString(). AFAIK, the console log output of a Date object is not standardized, so either is valid. If you want specific output, call a function and log that instead.
,
May 22 2017
Sorry, to clarify - I meant you are seeing .toISOString() in FireFox. Chrome is using .toString(). Again, either are fine for debug output. The input is indeed supposed to be interpreted as local time, per ECMAScript 2015 (ES6) section 20.3.1.16. This changed from ES5.1, which interpreted the input as UTC when no offset was supplied. There is no bug here.
,
May 22 2017
As far as your comment about moment goes, you're just using it wrong. If you want to interpret the input as UTC and convert to local time, that would be:
moment.utc("2017-05-22T14:00:00").local().format()
//=> "2017-05-22T19:30:00+05:30"
,
May 22 2017
|
|||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||
Comment 1 by stripat...@gmail.com
, May 22 2017*correction to reproduce Steps to reproduce the problem: 1. Open developer console 2. Enter this: new Date("2017-05-22T14:00:00"); 3. Output will be incorrect local timeZone date