<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JavaScript在线时钟,时间</title>
<script type="text/javascript">
function tim(){
var now=new Date;
this.year = now.getFullYear();
this.tmonth = now.getMonth() + 1;
this.tday = now.getDate();
this.week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")[now.getDay()];
this.month = tmonth < 10 ? "0" + tmonth : tmonth;
this.day = tday < 10 ? "0" + tday : tday;
this.hour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
this.minute = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
this.second = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
document.getElementById("timespan").innerHTML="今天是"+year+"年"+month+"月"+day+"日,"+hour+":"+minute+":"+second+","+week;
var mm=setTimeout("tim()","1000");
}
</script>
</head>
<body onLoad="tim()">
<span id="timespan"></span>
</body>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JavaScript在线时钟,时间</title>
<script type="text/javascript">
function tim(){
var now=new Date;
this.year = now.getFullYear();
this.tmonth = now.getMonth() + 1;
this.tday = now.getDate();
this.week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")[now.getDay()];
this.month = tmonth < 10 ? "0" + tmonth : tmonth;
this.day = tday < 10 ? "0" + tday : tday;
this.hour = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
this.minute = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
this.second = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
document.getElementById("timespan").innerHTML="今天是"+year+"年"+month+"月"+day+"日,"+hour+":"+minute+":"+second+","+week;
var mm=setTimeout("tim()","1000");
}
</script>
</head>
<body onLoad="tim()">
<span id="timespan"></span>
</body>
</html>