<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312"/>
<title>输出系统当前时间</title>
<style>
#box{
color:red;
font-size:16px;
width:300px;
margin:0 auto;
}
</style>
<script>
window.onload=function(){
showTime();
}
function check(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 date=myDate.getDate();
var d=myDate.getDay();
var week=new Array(7);
week[0]="星期日"
week[1]="星期一"
week[2]="星期二"
week[3]="星期三"
week[4]="星期四"
week[5]="星期五"
week[6]="星期六"
var h=myDate.getHours();
var m=myDate.getMinutes();
var s=myDate.getSeconds();
h=check(h);
m=check(m);
s=check(s);
document.getElementById("box").innerHTML = year+"年"+month+"月"+date+"日"+week[d]+h+":"+m+":"+s;
setTimeout(showTime,500);
}
</script>
</head>
<body>
<div id="box">11111</div>
</body>
</html>