<html>
<head>
<script type="text/javascript">
function settime() {
var date = new Date();
var year = date.getYear();
var month = date.getMonth()+1;
var day = date.getDate();
var h = date.getHours();
var m = date.getMinutes();
var s = date.getSeconds();
var week = date.getDay();
m=changetime(m);
s=changetime(s);
var arr =new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
var str = year+"年"+month+"月"+day+"日 "+h+":"+m+":"+s+" "+arr[week];
document.getElementById("div1").innerHTML=str;
setTimeout("settime()",500);
}
function changetime(time) {
if( time<10 ) {
return "0"+time;
}else {
return time;
}
}
</script>
</head>
<body onLoad="settime()">
<div id="div1"> </div>
</body>
</html>
在网页中显示一个时钟 (js)
最新推荐文章于 2022-09-24 01:55:19 发布