Novice question. I’ve got a string in the following format:
var dateStr = '2012-4-14';
I want to make it into a JavaScript Date object. The following creates a Date object in Chrome, but is NaN in IE8:
var myDate = new Date(dateStr);
What should I be doing differently – should I split the string?
Thanks!
Try splitting your date string into year, month, day and instantiating your date differently.
Note that this will only work if you can guarantee that your date string will be of the same format each time.