<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>倒计时时差效果</title>
</head>
<body>
<div id="content">
<div id="show"></div>
</div>
<script type="text/javascript">
window.onload=function(){
showTime();
}
//函数区域
//分、秒补位函数
function checkTime(i){
if(i<10){
i="0"+i;
}
return i;
}
//时间展示函数
function showTime(){
var mydate=new Date();
var year=mydate.getFullYear();
var month= mydate.getMonth()+1;
var dateArray=['星期天','星期一','星期二','星期三','星期四','星期五','星期六'];
var xingqi=mydate.getDay();
var day=mydate.getDate();
var h=mydate.getHours();
var m=mydate.getMinutes();
var s=mydate.getSeconds();
var m=checkTime(m);
var s=checkTime(s);
var show=document.getElementById('show');
show.innerHTML=year+'年'+month+'月'+day+'日'+dateArray[xingqi]+h+':'+m+':'+s;
setTimeout(showTime,1000);
}
</script>
</body>
</html>
joffyzou
相关分类