IE browser Date Time Issue

On IE 11 browser the below statement is returning an invalid date response: new Date("2016-03-09T22:40:05.653-0800"). Where as on the chrome/firefox it is returning the valid date.

Please suggest me !!

Jon Skeet
people
quotationmark

This is nearly an ISO-8601 formatted date/time, but not quite... the UTC offset doesn't have a colon in it. It looks like Chrome and Firefox aren't being quite as picky with their ISO-8601 parsing as IE.

If you change the code to:

new Date("2016-03-09T22:40:05.653-08:00")

... then it's fine in both Chrome and IE11. (I haven't tested Firefox, but I'd expect it to be fine.)

"-0800" is a valid UTC offset in basic format of ISO-8601, but that doesn't have colons. Neither Chrome nor IE want to handle a properly-formatted basic ISO-8601 value, e.g. "20160309T224005-0800".

people

See more on this question at Stackoverflow