The Safari browser in IOS5 and above (not including IOS5) correctly interprets the date object of the new date (' 2013-10-21 ') in JavaScript. However, the IOS5 version of Safari explains that new date (' 2013-10-21 ') is not correct, and the return in IOS5 Safari is always "Invalid date". Later I found the information on the Internet, originally the low version of Safari explained that the new date (' 2013-10-21 ') This object is not the same, in IOS5 Safari does not support this type of writing, and it supports the wording of the new date (' 2013 ', ' 10 ', ' 21 ') , this will solve the "Invalid date" problem and return a JavaScript date back. But then the problem arose, and date returned, but the data returned by the method in the Date object was not what I wanted, and the returned data were all incorrect. Specific is what reason I also not too clear, also please know the principle of the prawn to guide! Now return to the Date object. GetMonth () One months more than normal! and. GetDay () The day of the week returned is also incorrect! ╮(╯▽╰)╭ annoyed Ah, torture ah .... I began to scold the development of the safari of these people, but scold to scold the problem or to solve, or wages on the wood has! Oh! Then I checked a lot of foreign technical blog, finally found a solution, originally wanted to IOS5 in the safari can correctly parse the new Date () so it must be written
new Date (' 2013/10/21 '); or
var d = new Date (date);
D = d.getfullyear () > 0? D:new Date (Date.parse (Date.replace (/-/g, "/")));
Write yourself a piece of code
This.state.clearTime = SetInterval (() =>{
Let date = new Date ();
This.props.desk_start_time from backstage ' 201612231933 ' turn him into 2016/12/23 19:33
Let Datet = This.props.desk_start_time.replace (/(\d{4}) (\d{2}) (\d{2}) (\d{2}) (\d{2})/, "$1/$2/$3 $4:$5");
In milliseconds, so you want to divide 1000
Let DateTime = (date-new date (datet))/1000;
}). 1000}
New Date () ISO does not support compatibility issues