html代码如下:
现在是<span id="TimeSpan"></span>
<script type="text/javascript">
ShowTime();
</script>
Js脚本
<script type="text/javascript">
function ShowTime() {
now = new Date();
hour = now.getHours();
minute = now.getMinutes();
second = now.getSeconds();
var day = ["日", "一", "二", "三", "四", "五", "六", ];
time_str = (hour < 10) ? ("0" + hour) : hour;
time_str += ":";
time_str += (minute < 10) ? ("0" + minute) : minute;
time_str += ":";
time_str += (second < 10) ? ("0" + second) : second;
$$("TimeSpan").innerHTML = "" + (now.getFullYear()) + "年" + (now.getMonth() + 1) + "月" + (now.getDate() + 0) + "日 " + time_str + " 星期" + day[new Date().getDay()];
setTimeout('ShowTime()', 1000);
}
</script>