一个简单的钟表
<!DOCTYPE html>
<html>
<head>
<title>
date
</title>
<script type="text/javascript">
function showdate(){
var mydate=new Date();
var y=mydate.getFullYear();
var M=mydate.getMonth()+1;
var d=mydate.getDate();
var h=mydate.getHours();
var m=mydate.getMinutes();
var s=mydate.getSeconds();
function date(x){
if(x>=10){
return x;
}
return "0"+x;
}
var m=date(m);
var s=date(s);
document.getElementById("p1").innerHTML=y+"/"+M+"/"+d+"<br/>"+h+":"+m+":"+s;
setTimeout("showdate()",500)
}
</script>
</head>
<body onload="showdate()">
<p id="p1"></p>
</body>
</html>