When I was working on mobile Web recently, I successfully debugged it with Chrome on the PC, but strange problems appeared when I tested it on the iPhone. After a series of debugging, it was found that there was a problem related to the date. At first I suspected it was a problem in the production environment, but the same problem also occurred when debugging locally with the Mac version of Safari. After consulting some information, I found that there is a strange problem in Safari's support for JavaScript's new Date function.
Usually, due to being accustomed to the datetime format in SQL, dates are formatted in yyyy-mm-dd. However, Safari does not support such a format, so when you enter the following statement, an empty time will be returned.
new Date('2016-04-17');
The format supported by Safari is yyyy/mm/dd. The main difference lies in the dash - and the slash /, and the slash format can also run normally in other common browsers. , so you just need to replace them with slashes. The conversion function is as follows:
new Date('2016-04-17'.replace(/-/g, "/"));