1

I am getting date values from RestAPI, I'm trying to perform some calculation in JS and it works fine in Chrome and Firefox but on Safari browser(v12) it returns NaN.

Date.parse("2018-11-14 12:52:30.243784+05:30") // returns NaN on safari
Murtuza Z
  • 5,639
  • 1
  • 28
  • 52
  • 1
    Was writing up an actual answer to this problem before it was closed. For Safari 12 this can be easily solved by adding the time separator (T) to your date so that it is a valid ISO8651 date. `Date.parse("2018-11-14 12:52:30.243784+05:30".replace(/ /, 'T'))` works fine in Safari (or better yet you could ask the API maintainer to fix it). – Karl-Johan Sjögren Nov 14 '18 at 11:58
  • I'm nominating this to be reopened since the "duplicate" question is seven years old and the code in the question works fine in Safari since a few versions back and doesn't apply here (specifically asked for Safari 12). – Karl-Johan Sjögren Nov 14 '18 at 12:01
  • @Karl-JohanSjögren Thanks it worked – Murtuza Z Nov 14 '18 at 13:01
  • @Karl-JohanSjögren The appropriate action would be to post that answer to the marked duplicate. – Mark Rotteveel Nov 14 '18 at 18:28
  • @MarkRotteveel That answer wouldn't fit the duplicate since it isn't valid for a browser from 7 years (or more) ago as well as the error in the old question doesn't exist in a new browser. Just because a question has the subject "X is different between Y and Z" it can't possibly cover every discrepancy in between every version of Y and Z for all time. – Karl-Johan Sjögren Nov 15 '18 at 06:06
  • @Karl-JohanSjögren That question is generic, so an answer about a recent version is appropriate there. – Mark Rotteveel Nov 15 '18 at 09:00

0 Answers0