当前位置: 代码迷 >> Web前端 >> 记时 传入 时间戳
  详细解决方案

记时 传入 时间戳

热度:397   发布时间:2012-10-18 13:46:55.0
倒计时 传入 时间戳

//计算倒计时 ,时间戳 id?

function jisuandaojishi(id , closeTime)

{

//var closeTime = endtime - currenttime;

var displayTime;

function showTime(){

var day = Math.floor(closeTime / (60 * 60 * 24));

var hour = Math.floor(closeTime / (3600)) - (day * 24);

var minute = Math.floor(closeTime / (60)) - (day * 24 * 60) - (hour * 60);

var second = Math.floor(closeTime) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);

closeTime -= 1;

var html = day+'天'+hour+'小时'+minute+'分'+second+'秒';

jQuery('#'+id).html(html);

if(closeTime == -1)

{

clearInterval(displayTime);

document.location.href = document.location.href;

return;

}

}

showTime();

displayTime = setInterval(function(){

showTime();

}, 1000)

}

  相关解决方案