qfedu-web/www/js7.html

40 lines
957 B
HTML
Raw Permalink Normal View History

2023-09-18 11:21:50 +08:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="author" content="flykhan" />
<meta name="keywords" content="c c++ 物联网" />
<title>实时显示日期和时间</title>
</head>
<body>
<div id="dateDIV"></div>
<script>
// js 中的匿名函数: function(){}
// js 中的箭头函数: ()=>{}
// (n,m) => n*m n*m就是匿名函数返回的值
setInterval(() => {
// Date 日期时间类
let cur_date = new Date();
let date_str =
"" +
cur_date.getFullYear() +
"年" +
cur_date.getMonth() +
"月" +
cur_date.getDate() +
"日" +
" " +
cur_date.getHours() +
"时" +
cur_date.getMinutes() +
"分" +
cur_date.setSeconds() +
"秒";
dateDIV.innerText = date_str;
}, 1000);
</script>
</body>
</html>