小儿,来个js倒计时
注意:是读本地时间啊
CODE如下
<html> <head> <title>倒计时</title> <body> <script> var now = new Date("02/09/2015 " + 10 + ":" + 30 + ":" + 30);//开始时间 function GetServerTime() { var urodz = new Date("02/10/2015 10:30:30");//截止时间 now.setTime(now.getTime()+250); days = (urodz - now) / 1000 / 60 / 60 / 24; daysRound = Math.floor(days); hours = (urodz - now) / 1000 / 60 / 60 - (24 * daysRound); hoursRound = Math.floor(hours); minutes = (urodz - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound); minutesRound = Math.floor(minutes); seconds = (urodz - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound); secondsRound = Math.round(seconds); document.getElementById("date").innerHTML = daysRound; document.getElementById("time").innerHTML = hoursRound + ":" + minutesRound + ":" + secondsRound; } setInterval("GetServerTime()",250); </script> <span id="date"></span> <span class="white14b">天</span> <span id="time"></span> </body> </html>
本文出自 “PHPer许琴-专注于PHP技术” 博客,请务必保留此出处http://xuqin.blog.51cto.com/5183168/1613233
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。