倒计时

/*审核倒计时*/
 
var timer=function () {
var curTime=new Date();
var endTime=new Date(curTime.getFullYear(),curTime.getMonth(),curTime.getDate()+3);//3天后
 
var a=endTime.getTime()-curTime.getTime();
var intDiff = parseInt(a); //倒计时总秒数量
var day = 0,
hour = 0,
minute = 0,
second = 0; //时间默认值
if (intDiff > 0) {
day = Math.floor(intDiff / (60 * 60 * 24 * 1000));
hour = Math.floor(intDiff / (60 * 60*1000)) - (day * 24);
minute = Math.floor(intDiff / 60/1000) - (day * 24 * 60) - (hour * 60);
second = Math.floor(intDiff/1000) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
}
if (hour <= 9) hour = '0' + hour;
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
 
$('.wait_time').html(day + "天"+ hour + '时'+minute + '分'+ second + '秒');
intDiff--;
}
timer();
setInterval(timer, 1000);
 
posted @ 2017-04-20 15:31  世界,太精彩  阅读(197)  评论(0编辑  收藏  举报