Search code examples
javascriptreactjsipadredux-form

new Date does not give me correct value


I get this problem with datefields ONLY on iPad. On my PC with Chrome and Edge it works perfectly fine.

Can anyone shed some light on this for me please?

on BEFORE I get 2000-01-03 00:00:00

alert("BEFORE ---  "+formatedDate);  
formatedDate = new Date(formatedDate) == "Invalid Date" ? 0 : new Date(formatedDate);
alert("AFTER   ---   "+formatedDate);  

on AFTER I get 0


Solution

  • Whatever is setting formatedDate in your code, it is not a properly formatted ISO date string.

    If it was formatted properly, it should be 2000-01-03T00:00:00Z (timezone depending).

    Safari cannot create a date object with the date string you are providing.