2

I am trying to figure out why Date.parse (javascript) returns NaN when applied to a seemingly valid ISO 8601 date string when IE9 is in Quirks Mode. It works fine in Standards mode.

//ReturnsNaN in Quirks Mode, 1270574382557 in Standards Mode
document.write(Date.parse("2010-04-06T17:19:42.557"));  

//Returns NaN in Quirks Mode, 1270512000000 in Standards Mode
document.write(Date.parse("2010-04-06"));       

In contrast, the following works in both Quirks and Standards for me

//Returns 1270549182000 in both Quirks and Standards Modes  
document.write(Date.parse("2010/04/06T17:19:42"));  

Is anybody else seeing this behavior? If so, any ideas on why Date.parse is returning NaN?

dda
  • 309
  • 1
  • 3
  • 15
  • Perhaps this will help, perhaps not: [Two similar Date.parse cases return different results.](http://stackoverflow.com/questions/2587345/javascript-date-parse) – sdleihssirhc Nov 17 '11 at 19:01

1 Answers1

1

First of all you should understand that quirks mode is basically an IE5 compatibility mode.

It is triggered by not having a valid declaration. The main effect is that it causes the browser to use the IE5 box-model, which means that all your paddings, margins and borders, and anything else which affects the size of a box will be incorrect.

So your Date.parse doesn't work because there were no such feature - "parse ISO 8601 date" at those dates.

Pavel Podlipensky
  • 8,201
  • 5
  • 42
  • 53
  • Gotcha. Thanks for the info! I knew about the box-model, bu I did not realize that Quirks affected dates, et al. – dda Nov 17 '11 at 21:37