首页 > 代码库 > 倒计时

倒计时

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script type="text/javascript">
var time = setInterval(timer,1000);
timer();
function timer(){
var that = new Date(‘2017/4/2 00:00:00‘);
var oDate = new Date();
var a = that.getTime();
var b = oDate.getTime();
var c = a - b ;
if(c>=0){
var Tday = Math.floor(c/1000/60/60/24);
var Thouer =Math.floor( c/1000/60/60%24);
var Tmin =Math.floor(c/1000/60%60);
var Tsec =Math.floor(c/1000%60);
document.body.innerHTML = ‘距离清明短假‘+ Tday + ‘天‘ + Thouer + ‘小时‘ + Tmin + ‘分‘ + Tsec + ‘秒‘;
}
}


</script>
</body>
</html>

倒计时