开发者

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

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 开发者_Python百科browser? Thanks in advance.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜