-3

I'm trying to parse 2016-11-03 09:06:30.087 to a date object in javascript using the new Date() function.

It works fine in firefox however IE will not recognize it as a date.

Any tips? Thanks

James2356
  • 41
  • 4
  • 1
    Every question about parsing dates in JavaScript has been asked and answered here. Please search. – T.J. Crowder Nov 03 '16 at 10:41
  • What code did you use to get this result? – Ivar Nov 03 '16 at 10:42
  • I am trying to turn 2016-11-03 09:06:30.087 into a date object as it is a string initially – James2356 Nov 03 '16 at 10:44
  • Please refer the below link for the solution. http://stackoverflow.com/questions/2182246/date-constructor-returns-nan-in-ie-but-works-in-firefox-and-chrome –  Nov 03 '16 at 10:53
  • Possible duplicate of [How can I convert string to datetime with format specification in JavaScript?](http://stackoverflow.com/questions/476105/how-can-i-convert-string-to-datetime-with-format-specification-in-javascript) – Ivar Nov 03 '16 at 10:53

1 Answers1

0

The string given to the date constructor should be an RFC2822 or ISO 8601 formatted date. In your example it isn't. Try the following:

new Date("2012-11-02T19:30:00.000Z");

or using an alternate constructor:

new Date(2012, 11, 2, 19, 30, 0)