IE8 Javascript dates show NaN.

less than 1 minute read

As a web developer, I can honestly say I hate writing JavaScript code that works with Internet Explorer prior to version 10. It has various quirks to it that no other browsers have. For whatever reason Microsoft developed it this way trying to set standards rather than follow them.

So one common problem is with the Date Object. The problem only seems to exist when you are passing in a date into a date object such as:

var d = new Date("2014-02-24"); alert(d);

If you were to do that in Internet Explorer then you would get NaN. The issue is that Internet Explorer 8 doesn’t support the date format of “yyyy-mm-dd”. I have no idea why that would be. Also, I don’t have a list of all possible formats but one you can use is:

var d = new Date("02/24/2014");  // "mm/dd/yyyy"


var d = new Date(2011, 01, 24); // yyyy, mm-1, dd

If you keep that in mind, you should be okay.