I am formatting a date in the following way:
date = new Date(\"2013-05-12 20:00:00\");
formattedDate = new Date(date.getFullYear(),date.getMonth(),date.getDate()
I ran into this exact same issue today, do not use dashes as a seperator. This works fine in Chrome but not in Safari/iOS, replacing dashes with slashes fixes this issue. The Date function will otherwise break in Safari.
The following code will return the following
new Date('03-25-2017');
Chrome:
Sat Mar 25 2017 00:00:00 GMT+0100 (CET)
Safari:
Invalid Date
So, simply replace - with /.
The following code will return the following
new Date('03/25/2017');
Chrome:
Sat Mar 25 2017 00:00:00 GMT+0100 (CET)
Safari:
Sat Mar 25 2017 00:00:00 GMT+0100 (CET)