帶天數的倒計時
function countDown(dateline){
var timer=null,
//倒計時
current_time=Math.floor(new Date().getTime()/1000),
times=dateline-current_time;
if(times>0){
timer=setInterval(function(){
var day=0,
hour=0,
minute=0,
second=0;//時間默認值
if(times > 0){
day = Math.floor(times / (60 * 60 * 24));
hour = Math.floor((times- day * 24*60 * 60) / (60 * 60)) ;
minute = Math.floor((times- (day * 24 * 60* 60) - (hour * 60* 60) )/ 60) ;
second = Math.floor(times) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
}
if (day <= 9) day = '0' + day;
if (hour <= 9) hour = '0' + hour;
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
//
$('#day').html(day);
$('#hour').html(hour);
$('#minute').html(minute);
$('#second').html(second);
times--;
},1000);
if(times<=0){
clearInterval(timer);
}
}else{
$('#day').html('00');
$('#hour').html('00');
$('#minute').html('00');
$('#second').html('00');
}
}