<!DOCTYPE html>
<html>
<head>
<title>实时显示本地电脑时间(精确到毫秒)</title>
</head>
<body>
<h1>本地电脑时间(精确到毫秒):</h1>
<h1 id="clock"></h1>
<script>
function updateClock() {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, '0');
const day = String(now.getDate()).padStart(2, '0');
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
const milliseconds = String(now.getMilliseconds()).padStart(3, '0');
const timeString = `${year}-${month}-${day} ${hours}:${minutes}:${seconds} ${milliseconds}`;
document.getElementById('clock').textContent = timeString;
}
// 每毫秒更新一次时间
setInterval(updateClock, 1);
</script>
</body>
</html>
HTML 显示本地电脑时间(精确到毫秒)
转载请注明出处或者链接地址:https://www.qianduange.cn//article/6791.html
发布的文章
jQuery Ajax 设置请求头
2024-05-08 10:05:25
玩转代码|WordPress后台加载缓慢,加载无样式解决方法
2024-05-08 10:05:20
【JS】使用jQuery制作图片手风琴效果
2024-05-08 10:05:18
h5实现i18n语言切换
2024-05-08 10:05:17
【前端面试】谈谈你对jQuery中的ajax方法的了解
2024-04-20 17:04:44
jQuery报错:Uncaught ReferenceError: $ is not defined解决方法
2024-05-08 10:05:14
JQuery的属性(1)
2024-05-08 10:05:57
jQuery
2024-01-31 12:01:10
jQuery操作指南
2024-05-08 10:05:51
echarts3d柱状图
2024-05-08 10:05:50
大家推荐的文章