var date = new Date (' 2016-11-11 11:11:11 ');
document.write (date);
Recently in writing a time to judge a script, you need to convert the fixed string time to the timestamp for comparison, in doing the personal habit of using chrome as a debugging tool, after the basic code is complete, all normal;
Access with other browsers, well, IE is not compatible with Safari, returning the error "Invalid Date."
Think of the problem is a string format, changed to ' 2016/11/11 11:11:11 ' again test, the result is normal, think this should be no problem, and then continue to access the mobile phone browser, Android Normal, the iphone continues to complain,
Then change "Nov 11 2016 11:11:11", the same error, how to change all not
Racking my brains, I finally saw this solution on the forum:
var arr = "2016/11/11 11:11:11". Split (/[-: \/]/),
date = new Date (arr[0], arr[1]-1, arr[2], arr[3], arr[4], arr[5] C4/>document.write (date);
Finally can be compatible with all browsers, the conclusion:
Safari in the iphone can't explain time formats like Yyyy-mm-dd HH:mm:ss or Yyyy/mm/dd HH:mm:ss, and browsers such as Google Firefox have extended the format
Safari in the iphone format supported by YYYY,MM, DD,HH,MM,SS, this problem tangled me for a long time, really good want to pull out the Apple programmer to shoot 10 minutes, too TM Maverick. Irritating
The above is a small set to introduce the JS Ios/iphone safari incompatible JavaScript date () problem solution, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!