1 var New Date (' 2016-11-11 11:11:11 '); 2 document.write (date);
Recently write a time to judge the script, you need to convert the fixed string time to a timestamp to compare, when doing the personal habit of using chrome as a debugging tool,
After the code is basically complete, everything is OK;
Use other browsers to access, well, IE is incompatible with Safari and returns the error "Invalid Date".
Think of the problem of string format, changed to ' 2016/11/11 11:11:11 ' again test, the result is normal, thought this should be no problem, and then use the mobile browser to continue to access, Android Normal, the iphone continues to error,
Change "11 2016 11:11:11", still error, how to change
Racked his brains, and finally saw a solution on the forum:
1 var arr = "2016/11/11 11:11:11". Split (/[-: \/]/),2new Date (Arr[0], arr[1]-1, arr[2 ], arr[3], arr[4], arr[5]); 3 document.write (date);
Can finally be compatible with all browsers, conclusion:
Safari in the iphone can't explain the time format of Yyyy-mm-dd HH:mm:ss or Yyyy/mm/dd HH:mm:ss, and Google Firefox and other browsers have extended this format.
The iphone in the format supported by the Safari yyyy,mm, DD,HH,MM,SS, this problem tangled me for half a day, really want to pull out the Apple programmer to shoot 10 minutes, too TM Maverick. Irritating
JS Ios/iphone in Safari incompatible with date () issues in JavaScript