0

Firefox appears to change how it parses a common if non-ISO date format in Javascript.

Until version 62, it failed to parse this date format:

(new Date("02-Nov-2018")).toISOString() //==> "Invalid Date"

That was great because you could detect that and fall back to use custom date format with a library like moment

But now as of version 64 it "successfully" parses it as 2018 BCE, the end of the Agean bronze age:

(new Date("02-Nov-2018")).toISOString() //==> "-002018-11-02T04:56:02.000Z"

Stranger yet .toISOString() and .toLocaleString() return different date strings, and arguably at least one is incorrect:

(new Date("02-Nov-2018")).toLocaleString() //==> "11/2/2019, 12:00:00 AM"

By contrast, Chrome, Safari and IE parse it correctly.

Is there a way to get the old behavior back?

prototype
  • 7,249
  • 15
  • 60
  • 94
  • Sounds like a bug. Btw 63 throwed "Invalid date" aswell. – bigless Jan 09 '19 at 22:12
  • 2
    Parsing of strings other than those supported by ECMA-262 is implementation dependent, which includes between versions of browsers. Don't use the built–in parser and it won't surprise you. – RobG Jan 10 '19 at 00:01
  • See [What are valid Date Time Strings in JavaScript?](https://stackoverflow.com/questions/51715259/what-are-valid-date-time-strings-in-javascript) – str Jan 10 '19 at 10:14

0 Answers0