Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE Date.parse method returns NaN for Date with Time string

Tags:

javascript

We are trying parse the date with timestamp string, it blows up in IE but works fine FireFox.

Here are the code

alert(new Date(Date.parse("2010-01-31T12:00:00.233467-05:00")));

Any idea to make it work in IE browser? Thanks in advance.

like image 899
Senthil Elayappan Avatar asked Jun 15 '10 15:06

Senthil Elayappan


1 Answers

If you can put your input in this form:

YYYY/MM/DDThh:mm:ss

It will work.

Eg:

alert(new Date(Date.parse('2010-01-31T12:00:00.233467-05:00'.replace(/\-/ig, '/').split('.')[0])));

If you want the time zone, then you will have to find another way

like image 168
Bob Fincheimer Avatar answered Sep 29 '22 08:09

Bob Fincheimer