📄 19-2.html
字号:
<html>
<head>
<script language="JavaScript">
function showTime() {
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var day = now.getDay();
day = day==0?"天":day;
var hours = now.getHours();
var mins = now.getMinutes();
var secs = now.getSeconds();
var timeVal1 = "今天是:";
var timeVal2 = "现在时间:";
timeVal1 += year + "年";
timeVal1 += ((month < 10) ? " 0" : " ") + month + "月";
timeVal1 += date + "日 星期";
timeVal1 += day;
if (hours<12)
timeVal2 += "上午";
else
timeVal2 += "下午";
timeVal2 += ((hours <= 12) ? hours : hours - 12);
timeVal2 += ((mins < 10) ? ":0" : ":") + mins;
timeVal2 += ((secs <= 10) ? ":0" : ":") + secs;
document.clockForm.clock1.value = timeVal1;
document.clockForm.clock2.value = timeVal2;
}
function startClock(){
window.setInterval("showTime()", 1000);
}
</script>
</head>
<body onLoad="startClock()" >
<form name="clockForm">
<input type="text" name="clock1" size=30 readonly><br>
<input type="text" name="clock2" size=30 readonly>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -