最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - IE Date.parse method returns NaN for Date with Time string - Stack Overflow

programmeradmin3浏览0评论

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.

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.

Share Improve this question asked Jun 15, 2010 at 15:09 Senthil ElayappanSenthil Elayappan 911 gold badge1 silver badge2 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 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

发布评论

评论列表(0)

  1. 暂无评论