码迷,mamicode.com
首页 > 其他好文 > 详细

倒计时

时间:2016-08-16 21:42:05      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:

<body>

<div id="date"></div>                        

 

</body>

 

<script type="text/javascript">

 

function getTime () {

var now = new Date();

var future = new Date("01/01/2018 00:00:00");

var time = future.getTime() - now.getTime();

 

var days = parseInt(time/1000/60/60/24);

var hours = parseInt(time/1000/60/60%24);

var minutes = parseInt(time/1000/60%60);

var seconds = parseInt(time/1000%60);

 

document.getElementById("date").innerHTML = days + "天"+ hours + "时" + minutes + "分" + seconds + "秒";

}

setInterval(getTime,1000);

 

</script>

倒计时

标签:

原文地址:http://www.cnblogs.com/chenhongcai/p/5777672.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!