倒计时代码

 1     function getRTime(){
 2         var EndTime= new Date('2015/01/13 10:00:00'); //截止时间
 3         var NowTime = new Date();
 4         var t =EndTime.getTime() - NowTime.getTime();
 5 
 6         var d=Math.floor(t/1000/60/60/24);
 7         var h=Math.floor(t/1000/60/60%24);
 8         var m=Math.floor(t/1000/60%60);
 9         var s=Math.floor(t/1000%60);
10 
11         document.getElementById("t_d").innerHTML = d + "天";
12         document.getElementById("t_h").innerHTML = h + "时";
13         document.getElementById("t_m").innerHTML = m + "分";
14         document.getElementById("t_s").innerHTML = s + "秒";
15     }
16     setInterval(getRTime,1000);
<span id="t_d">00 天</span> <span id="t_h">00 时</span> <span id="t_m">00 分</span> <span id="t_s">00 秒</span>

 

posted @ 2015-01-12 10:47  安雅然  阅读(228)  评论(0编辑  收藏  举报