Quantcast
Channel: Code:Q
Viewing all articles
Browse latest Browse all 50

JavaScript Date parsing fun

$
0
0


Just bumped into an amusing anomaly in how Mozilla does date parsing in its JavaScript Date constructor. Quick, what date is returned by this code:

  document.write(new Date("31 03 2006"))
The result is:

  Thu Jul 03 2008 00:00:00 GMT+0200
31 is (of course) 2*12+7, and with July being the 7th month, it is all crystal clear. IE gives me a NaN, which makes more sense, I'd say.


Viewing all articles
Browse latest Browse all 50

Trending Articles