According to the ES5 specification, Date.parse will only work with a valid ISO 8601 . Everything else depends on the implementation (in practice IE <9 does not work with standard ISO dates, this requires a "/" seperator). Therefore, if you submit an invalid date (e.g. 2012-11-31), you can get anythying from 2012-12-01 until the error.
In your tests:
2012-12-31T23:59:60.000Z
should work, although probably not the way you expect. Using 60 seconds shows a second jump, this is not equivalent to 24:00:00, only Safari seems to be getting this right.
also:
2012-04-04T24:00:00.000Z
should work, it shows midnight at the end of April 4, 2012, so Firefox is mistaken there.
Formats that must be supported by ES5 implementations are in spec .
Oh, and you probably should also check for the lack of a “T” (since in some cases this, in my opinion, includes additional browsers) and different time zones, such as:
2012-04-03 23:50:00+10:00 2012-04-03 23:50:00-04:15 2012-04-03 23:50:00+10 20120403T235000+1000
etc. with the formats YYYYDDD and YYYYWWD, although implementation is not required to support them.
source share