Search code examples
javascriptgoogle-chromefirefoxiso

Firefox and Chrome return value of date toISOstring() is different


There appears to be a difference in the ISO String representation of a date object in Chrome and Firefox. If one runs the below sample code in Chrome and Firefox, different results are obtained:

new Date(  "1-Nov-2010 00:00 UTC").toISOString();

Firefox: -002010-11-01T00:00:00.000Z

Chrome: 2010-11-01T00:00:00.000Z

What is -00 and why does Firefox behave differently to Chrome?


Solution

  • It's just a non-standard date format. Firefox is parsing it and sees "oh, you want the year -2010", Chrome seems to parse it a bit better, but I'd just suggest not using that particular string format for the dates.