<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>动态时钟</title>
<script src="./clock.js"></script>
</head>
<body>
<h1 id="date"></h1>
<span id="msg"></span>
</body>
</html>
function showDateTime(){
var sWeek=new Array("日","一","二","三","四","五","六");
var myDate=new Date();
var sYear=myDate.getFullYear(); //年
var sMonth=myDate.getMonth()+1;//月
var sDate=myDate.getDate();//日
var sDay=sWeek[myDate.getDay()];//根据得到的数字日期,利用数组转换成汉子星期
//var h=myDate.getHours();//小时,太难了,后面再写。凑合看
//var m=myDate.getMinutes();
//var s=myDate.getSeconds();
document.getElementById("date").innerHTML=(sYear+"年"+sMonth+"月"+sDate+"日"+"星期"+sDay+"<br>")
//document.getElementById("msg").innerHTML=(h+m+s);
}
setTimeout("showDateTime()",1000)
window.onload=showDateTime()