1

All:

I wonder how can I build a Date() object from a string like:

2016-05-31 07:35:22+02:00

In IE 11?

In Firefox and Chrome, I can simply use new Date("2016-05-31 07:35:22+02:00") but not work in IE11

Any idea? Thanks

Kuan
  • 11,149
  • 23
  • 93
  • 201
  • Did you tried this? http://stackoverflow.com/questions/2182246/date-constructor-returns-nan-in-ie-but-works-in-firefox-and-chrome – GONG Jun 10 '16 at 16:05
  • Using the Date constructor or Date.parse for parsing strings is not recommended as parsing is largely implementation dependent and differs across browsers (as you've discovered). Far better to manually parse strings and provide the format to the parser, a library can help but a function for a single format isn't difficult. – RobG Jun 12 '16 at 22:18

1 Answers1

2

Add a T before the time in the string:

new Date('2016-05-31T07:35:22+02:00')

That worked in IE for me

jonny
  • 3,022
  • 1
  • 17
  • 30