Javascript Date from string giving different output from Chrome to Firefox Javascript Date from string giving different output from Chrome to Firefox google-chrome google-chrome

Javascript Date from string giving different output from Chrome to Firefox


From the spec:

However, the expression Date.parse(x.toLocaleString()) is not required to produce the same Number value as the preceding three expressions and, in general, the value produced by Date.parse is implementation-dependent when given any String value that does not conform to the Date Time String Format (15.9.1.15) and that could not be produced in that implementation by the toString or toUTCString method.

When creating a date object by passing a date string to the constructor, the method of parsing is exactly the same as Date.parse.

Your date format, using a 2 digit year, is not conforming to the standard. As such, it would seem that the way these dates are parsed is implementation specific, meaning that it depends upon the Javascript engine being used. In Google's case, it's usually V8, and in Firefox, it's TraceMonkey or Rhino I believe.

In short, you should really use 4 digit years, as there is no YY in the JS standard.