<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body onload="showTime()">
<script>
function showTime() {
var date = new Date();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
var str = `${hour}:${minute}:${second}`;
document.getElementById("time").innerHTML = str;
}
</script>
<div id="time"></div>
</body>
</html>
js--date的实例
最新推荐文章于 2022-05-25 21:55:04 发布