<html>
<head>
<title>在網頁中動態顯示當前日期和時間</title>
</head>
<body onload="showTime()">
<script language="JavaScript">
function showTime(){
var thetime=new Date(); // 初始化日期對象
document.getElementById( "timeArea").innerText = thetime.toLocaleString();
window.setTimeout( "showTime()",1000); //setTimeout (表達式,延時時間)其中延時時間以豪秒為單位(1000ms=1s)
}
</script>
<p id="timeArea" align="center">
</p>
</body>
</html>
摘自 ynz1219