Firefox 64 breaks some date parsing

时间:2019-01-09 22:00:17

标签: javascript date firefox

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?

0 个答案:

没有答案