日期:2014-05-16  浏览次数:20364 次

用js实现钟表
<html>
<meta charset='utf-8'/>
<head>
<script type="text/javascript">
function clock(){
var myDate=new Date();
var year=myDate.getYear();
var month=myDate.getMonth()+1;
var day=myDate.getDate();
var hour=myDate.getHours();
var mint=myDate.getMinutes();
var seconds=myDate.getSeconds();
var p=document.getElementById("p1");
p.innerHTML=year+"年"+month+"月"+day+"日"+hour+"时"+mint+"分"+seconds+"秒";
}
setInterval('clock()',500);
</script>
</head>
<body>
<div id='p1'></div>
</body>
</html>