显示时间的最简单方法
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>显示时间</title>
<script defer="defer">
var otime = document.getElementById("time");
weekStr = "日一二三四五六";
function showDateTime() {
today = new Date();
otime.innerHTML = today.toLocaleString() + ' 星期' + weekStr.charAt(today.getDay())
}
showDateTime();
setInterval("showDateTime();", 1000);
</script>
</head>
<body>
当前时间:<span id="time"></span>
</body>
</html>

浙公网安备 33010602011771号