📄 7-9.htm
字号:
<html>
<head>
<META content="text/html; charset=gb2312">
<TITLE>获取日期和时间的方法示例</TITLE>
<script Language="JavaScript">
<!--
var timeStr,dateStr;
function clock(){
now= new Date();
hours=now.getHours();
minutes=now.getMinutes();
seconds=now.getSeconds();
timeStr= "" + hours;
timeStr+=((minutes<10)? ":0" : ":")+ minutes;
timeStr+=((seconds<10) ? ":0" : ":")+ seconds;
document.clock.time.value = timeStr;
date= now.getDate();
month= now.getMonth()+1;
year= now.getYear();
dateStr= year+"年";
dateStr+= month+"月";
dateStr+=((date<10) ? "0":"")+date+"日";
document.clock.date.value = dateStr;
Timer = setTimeout("clock()",1000);
}
-->
</script>
</head>
<body onLoad="clock()">
<form name="clock">
现在的时间是:
<input type="text" name="time" size="8" value=""><br>
今天的日期是:
<input type="text" name="date" size="12" value="">
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -