<script language="JavaScript"> <!-- // function getQueryString(name) { var reg =new RegExp("(^|&)"+ name +"=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r !=null) return unescape(r[2]); return null; } var currentDate = new Date(); var strEndTime = getQueryString("EndTime");//http://www.abc.com/page.html?EndTime=2012/10/23 10:20:30 var EndTime=new Date(strEndTime); var days= EndTime - currentDate; EndTimeMsg = parseInt(days / 1000);//精确到秒 function show() { h = Math.floor(EndTimeMsg / 60 / 60); m = Math.floor((EndTimeMsg - h * 60 * 60) / 60); s = Math.floor((EndTimeMsg - h * 60 * 60 - m * 60)); document.getElementById("DD").innerHTML = parseInt(h/24); document.getElementById("HH").innerHTML = h; document.getElementById("MM").innerHTML = m; document.getElementById("SS").innerHTML = s; EndTimeMsg--; if (EndTimeMsg < 0) { document.getElementById("DD").innerHTML = "0"; document.getElementById("HH").innerHTML = "00"; document.getElementById("MM").innerHTML = "00"; document.getElementById("SS").innerHTML = "00";; } } setInterval("show()", 1000) // --> </script>
<div> <strong id="DD"></strong>天 <strong id="HH"></strong>时 <strong id="MM"></strong>分 <strong id="SS"></strong>秒 </div>
http://www.cnblogs.com/ricky_li/archive/2012/10/23/2735793.html
时间: 2024-09-30 00:15:49