Closed Bug 1345896 Opened 8 years ago Closed 8 years ago

Date object representation doesn't match to Google Chrome's console (toISOString vs toString)

Categories

(DevTools :: Console, defect)

51 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1073533

People

(Reporter: quentin.lamamy, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:51.0) Gecko/20100101 Firefox/51.0 Build ID: 20170125094131 Steps to reproduce: 1) Open a scratchpad 2) paste var date = new Date(2017,1,1); console.log(date); 3) look at your console @dditional data : same issue on nightly version Actual results: Date 2017-01-31T23:00:00.000Z Expected results: Date 2017-01-01T23:00:00.000Z
Google Chrome output, as expected : Wed Feb 01 2017 00:00:00 GMT+0100 (CET)
"2017-01-31T23:00:00.000Z" and "Wed Feb 01 2017 00:00:00 GMT+0100 (CET)" are the same time. the difference comes from how the console shows the date object. new Date(2017,1,1).toString() is "Wed Feb 01 2017 00:00:00 GMT+0100 (CET)" and new Date(2017,1,1).toISOString() is "2017-01-31T23:00:00.000Z"
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
this is not about JS engine's behavior, but just an representation in devtools console. to be clear, the expected result in comment #0 is not correct: > Expected results: > > Date 2017-01-01T23:00:00.000Z
Component: JavaScript Engine → Developer Tools: Console
Product: Core → Firefox
Summary: Date object constructor don't work as expected → Date object representation doesn't match to Google Chrome's console (toISOString vs toString)
Feb 01 2017 mean 2017-01-31 ? Are you serious ? I can understand thei is something like 1 or 2 days because of timezone change but 30 day...
Feb 01 2017 = 2017-02-01 and there's 1 hour difference (23:00 vs 00:00) because of GMT vs CET just to be sure, the 2nd parameter of Date constructor is 0-origin (0 = Jan, 1 = Feb)
Oh well, just understand, omg, sorry for openning this useless bug. The is no consensus on the default way to dump a date object in console ? I now understand why my calendar sucks....
(In reply to Quentin Lamamy from comment #6) > The is no consensus on the default way to dump a date object in console ? I've moved this bug to developer tools console component, to see if current output is better than google chrome's one. let's wait for a response :)
Ok thanks
There's already a bug open requesting the use of the local timezone when displaying Date.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → DUPLICATE
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.