I have the following line, which generates a valid timestamp in FF and Chrome:
new Date('2012 11 2 00:00:00 GMT').getTime();
However, in IE9, I get NaN. What needs to be done differently to get this line to be cross browser compatible?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The date format you are using should conform to the EMCAscript spec, it just so happens that Firefox and Chrome are more forgiving about parsing.
The format should be:
So try this:
This will not work in older versions of IE. If you need full compatability then refer to the other answer.