Demand and thinking
Need to focus on thisEnd time
When you want to show upside down. The idea is to use the settimeout () function.
encountering problems
Database types passed on toIOS
cannot be correctly analyzed
code
// Countdown function execute once a second
setInterval(daojishi,1000);
// The countdown function used EACH to traverse all the time you need to deal with
function daojishi(){
$(".truetime").each(function(){
var end= $(this).html();
var end_on=formatStr(end);// Solve the problem of incompatibility of iOS mobile phones
var curtime=new Date();
var endtime=new Date(end_on);
var lefttime= parseInt((endtime.getTime()-curtime.getTime())/(1000));
if (lefttime>0) {
var day=parseInt(lefttime/(24*60*60));
var hours=parseInt( (lefttime/(60*60))%24);
var minutes=parseInt( (lefttime/(60))%60);
var seconds=parseInt( (lefttime)%60);
hours =checkout(hours);
minutes =checkout(minutes);
seconds =checkout(seconds);
var title =day+'& nbsp; Sky & nbsp;'+hours+'& nbsp; hours & nbsp;'+minutes+'& nbsp; divided & nbsp;'+seconds+'& nbsp; second & nbsp;';
}else{
var title="Time End"
}
$(this).next('span').html(title);
});
};
The time for the database is 2016-06-08 This time is not compatible with an unfarished time format, so the following functions are used to turn it into 2016/06/08
Solution
function formatStr(str) {
str=str.replace(/-/g,"/");
};
Thinking of the program
In countdown, use
var curtime=new Date();
This function acquisition is not appropriate for the client time. Modify the local current time to grab things! Intersection Intersection Take the system time and then subtract the results, but the corresponding background processing time will affect the accuracy of the countdown! Intersection So what to do to think!