[javascript]代码库
<div id="container">离2012世界末日还有 <span id="downtime"
style="color: #069"></span></div>
<script>
function downTime() {
var timeout = window.setTimeout(downTime, 100);
var endTime = new Date("12-21-2012 0:0:0"); // 倒计时结束时间
var today = new Date();
var timeold = (endTime.getTime() - today.getTime());
if (timeold <= 100) {
window.clearTimeout(timeout);
document.getElementById("container").innerHTML = "原来没事啊,虚惊一场!";
return;
}
var sectimeold = timeold / 1000;
var secondsold = Math.floor(sectimeold);
var msPerDay = 24 * 60 * 60 * 1000;
var e_daysold = timeold / msPerDay;
var daysold = Math.floor(e_daysold);
var e_hrsold = (e_daysold - daysold) * 24;
var hrsold = Math.floor(e_hrsold);
var e_minsold = (e_hrsold - hrsold) * 60;
var minsold = Math.floor((e_hrsold - hrsold) * 60);
var e_seconds = (e_minsold - minsold) * 60;
var seconds = Math.floor((e_minsold - minsold) * 60);
var decimals = Math.floor((e_seconds - seconds) * 10);
document.getElementById("downtime").innerHTML = daysold + "天" + hrsold
+ "小时" + minsold + "分" + seconds + "." + decimals + "秒";
}
downTime();
</script>
高级设计师
by: 神马 发表于:2012-08-28 13:04:46 顶(0) | 踩(0) 回复
<div> 离2012世界末日还有 114天10小时55分47.5秒 </div> <div> </div> <div> 快了 </div>
回复评论