标签:
<script>
function timerOver(year, month, day) {
window.setInterval(function() {
var now = new Date(),
endDate = new Date(year, month - 1, day),
leftTime = endDate.getTime() - now.getTime(),
leftSecond = parseInt(leftTime / 1000),
day1 = Math.floor(leftSecond / (24 * 3600)),
hour = Math.floor((leftSecond - day1 * 24 * 3600) / 3600),
minute = Math.floor((leftSecond - day1 * 24 * 3600 - hour * 3600) / 60),
second = Math.floor(leftSecond - day1 * 24 * 3600 - hour * 3600 - minute * 60);
if (day1 < 10) day1 = "0" + day1;
if (hour < 10) hour = "0" + hour;
document.body.innerHTML = "距离" + year + "年" + month + "月" + day + "日还有:" + day1 + "天" + hour + "小时" + minute + "分" + second + "秒";
}, 1000)
};
timerOver(2016, 5, 1);
</script>
标签:
原文地址:http://www.cnblogs.com/mouse2417/p/5168222.html