⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 7-9.htm

📁 JavaScript学习的网页教程。内容简单易懂
💻 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 + -