前端時間倒計時方案

 

<script>
var i=0;
function showtime(){html

//須要倒計時的時間節點
var gameTime = $("#gameTime").val();
if(gameTime ==null || gameTime==""){
return false;
}
var endyear=gameTime.substring(0,4);
var endmonth=gameTime.substring(5,7);
var endday=gameTime.substring(8,10);

//競猜時間截止於開賽前1小時;
var endh=gameTime.substring(11,13);
var endms=gameTime.substring(13,19);

var endhms=endh+endms;
//後臺傳過來的當前系統時間
var sTime = new Date('${sTime}');
var enddate=endyear+"/"+endmonth+"/"+endday+" "+endhms;
var eTime=new Date(enddate);spa

i=i+1;
var sumSecond=parseInt((eTime.getTime()-(sTime.getTime()+(i*1000)))/1000);
var showSecond=sumSecond%60;
var sumMinute=(sumSecond-showSecond)/60;
var showMinute=sumMinute%60;
var sumHour=(sumMinute-showMinute)/60;
var showHour=sumHour%24;
var showData=(sumHour-showHour)/24;
if(showSecond>-1){
$("#showday").html(showData);
$("#showhour").html(showHour);
$("#showminute").html(showMinute);
$("#showsecond").html(showSecond);htm

//循環此方法
timerID=setTimeout("showtime()",1000);
}else{
$("#time").html("距離競猜結束:<span>已結束</span>");
}
}
</script>blog

相關文章
相關標籤/搜索