HTML 实时显示本地电脑时间(精确到毫秒)

html 复制代码
<!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>
相关推荐
m0_50272495几秒前
vue3生成pdf
前端·javascript·vue.js·pdf
@不误正业2 分钟前
2026-05-16-多Agent协作框架深度实战-从ReAct到Plan-and-Execute全架构演进
前端·react.js·架构
我命由我123452 分钟前
PHP - PHP 简易 Web 服务器、基础接口开发
服务器·开发语言·前端·php·intellij-idea·idea·intellij idea
咖喱o4 分钟前
IPv6
服务器·前端·网络
海上彼尚5 分钟前
Nodejs也能写Agent - 6.基础篇 - Agent
前端·人工智能·后端·node.js
2501_940041749 分钟前
纯前端实战:5个高复杂度业务与交互场景
前端
renke336413 分钟前
写给前端的 CANN-torchtitan-npu:昇腾PyTorch Titan适配到底是啥?
前端·人工智能·pytorch·cann
lihaozecq15 分钟前
Agent 开发的 skills 机制设计 - 渐进式披露
前端·agent·ai编程
安生生申19 分钟前
uni-app 连接 JDY-31 蓝牙串口模块实践
c语言·前端·javascript·stm32·单片机·嵌入式硬件·uni-app
Restart-AHTCM23 分钟前
LangChain学习之模型 I/O 与输出解析器 (Output Parsers)(3/8)
前端·学习·langchain