9

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.

1 Answers1

13

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

Bob Fincheimer
  • 17,978
  • 1
  • 29
  • 54
  • It appears that Firefox and Opera behave the same way. IE and Safari behave the same way too. – ojreadmore May 10 '11 at 21:16
  • I tested this with IE8 and found I had to also remove the 'T' to get the correct time. i.e. `date.replace(/\-/ig, '/').replace(/T/, ' ').split('.')[0]` – benrwb Dec 17 '13 at 11:12