Apple iOS time shows NaN

1. The cause

During the development of WeChat, the test time of the Android mobile phone is displayed normally, and the IOS display shows NAN, and the reason is that the date format is "2018-05-03". iOS phones or browsers do not support this type of date format.

2. The phenomenon is as follows;


3. Solution:

new Date('2017-09-18 14:58:32').getTime(); //Unable to get the timestamp on ios and displaying NaN

Change to:

new Date("2018-02-15 20:30:00".replace(/-/g,'/')).getTime(); // Solve the problem, both android and ios are displayed normally

 

Guess you like

Origin blog.csdn.net/qq_35432904/article/details/121807835