帮我写一个html时间代码
时间: 2023-03-26 16:00:57 浏览: 81
好的,以下是一个简单的 HTML 时间代码:
<!DOCTYPE html>
<html>
<head>
<title>时间</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.">
</head>
<body>
<p>现在的时间是:</p>
<p id="time"></p>
<script>
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() + 1;
var day = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
document.getElementById("time").innerHTML = year + "年" + month + "月" + day + "日 " + hour + ":" + minute + ":" + second;
</script>
</body>
</html>
阅读全文