/*倒计时*/ lcf.downTime = function (endTime,obj,callback){ /*基本判断*/ if(!endTime || typeof endTime !== "string") return false; /*基本判断*/ if(!obj || typeof obj !== "object") return false; /*获取日期的毫秒*/ var endTime = Date.parse(endTime); /*定时器*/ var timer = setInterval(function () { var nowTime = +new Date(); /*2个时间的差 毫秒*/ var minus =endTime - nowTime; /*相差的天数*/ var day = parseInt(minus/1000/60/60/24); /*相差的小时*/ var hours = parseInt(minus/1000/60/60%24); /*相差的分钟*/ var mintue = parseInt(minus/1000/60%60); /*获取相差的秒*/ var second = parseInt(minus/1000%60); if(minus<=0){ clearInterval(timer); day =0; hours =0; mintue =0; second =0; }else{ obj[0].innerHTML = parseInt(hours/10); obj[1].innerHTML = hours%10; obj[3].innerHTML = parseInt(mintue/10); obj[4].innerHTML = mintue%10; obj[6].innerHTML = parseInt(second/10); obj[7].innerHTML = second%10;} },1000); callback && callback(); };
/*倒计时*/ lcf.downTime = function (endTime,obj,callback){ /*基本判断*/ if(!endTime || typeof endTime !== "string") return false; /*基本判断*/ if(!obj || typeof obj !== "object") return false; /*获取日期的毫秒*/ var endTime = Date.parse(endTime); /*定时器*/ var timer = setInterval(function () { var nowTime = +new Date(); /*2个时间的差 毫秒*/ var minus =endTime - nowTime; /*相差的天数*/ var day = parseInt(minus/1000/60/60/24); /*相差的小时*/ var hours = parseInt(minus/1000/60/60%24); /*相差的分钟*/ var mintue = parseInt(minus/1000/60%60); /*获取相差的秒*/ var second = parseInt(minus/1000%60); if(minus<=0){ clearInterval(timer); return false; }else{ obj[0].innerHTML = parseInt(hours/10); obj[1].innerHTML = hours%10; obj[3].innerHTML = parseInt(mintue/10); obj[4].innerHTML = mintue%10; obj[6].innerHTML = parseInt(second/10); obj[7].innerHTML = second%10;} },1000); callback && callback(); };