Don't say much, please look at the following code
Pc:
1.html page:
<div class= "ATime" >
<em id= "t_d" ></em>
<em id= "T_h" ></em>
<em id= "t_m "></em>
<em id=" t_s "></em>
</div>
2.js:
<script type= "Text/javascript" >
function Getrtime () {
var end = "<?php echo $info [' end_date '];?>" + "23:59:59";
var endtime= new Date (end);
var nowtime = new Date ();
var t =endtime.gettime ()-nowtime.gettime ();
var d=0;
var h=0;
var m=0;
var s=0;
if (t>=0) {
d=math.floor (t/1000/60/60/24);
H=math.floor (t/1000/60/60%24);
M=math.floor (t/1000/60%60);
S=math.floor (t/1000%60);
}
document.getElementById ("T_d"). InnerHTML = D;
document.getElementById ("T_h"). InnerHTML = h;
document.getElementById ("T_m"). InnerHTML = m;
document.getElementById ("t_s"). InnerHTML = S;
}
SetInterval (getrtime,1000);
</script>
The above code has an error in Safari because:
The Safari browser in the IOS5 version (without IOS5) correctly interprets the Date object for new date (' 2013-10-21 ') in JavaScript.
But in the IOS5 version, Safari explains that new date (' 2013-10-21 ') is not correct, and that IOS5 's safari is always returned with "Invalid date."
I later looked up the information on the Internet, which was originally a low version of Safari explaining the object of new Date (' 2013-10-21 '), which is not supported by Safari in IOS5,
And it's supported by the new date (' 2013 ', ' 10 ', ' 21 ') so that it can solve the "Invalid date" problem and return a JavaScript date back.
If you want safari in IOS5 to parse new Date correctly, you have to write this.
New Date (' 2013/10/21 '); or var d = new Date;d = D.getfullyear () > 0? D:new Date (Date.parse (Date.replace (/-/g, "/"));
The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring some help, but also hope that a lot of support cloud Habitat community!