Unix 时间戳转换器

将日期/时间值转换为 Unix 秒、毫秒和 ISO 字符串。

// about

工具介绍

计算机使用从 1970 年 1 月 1 日算起的总秒数来记录时间(称为 Unix 时间戳)。本工具能将这些长数字转换为人类可读的年月日,或将日期转换回数字。

如何使用

  1. 粘贴时间戳数字或选择具体日期。
  2. 点击“转换”按钮。
  3. 查看转换后的本地时间和 UTC 标准时间。

人们为何使用此工具

  • 将类似 1700000000 的数字即时翻译为年月日和具体时间。
  • 同时支持 10 位(秒)和 13 位(毫秒)格式。
  • 非常适合排查服务器日志、代码报错和系统时间。

常见问题解答 (FAQ)

什么是 Unix 时间戳?

它是自 UTC 时间 1970 年 1 月 1 日午夜起经过的总秒数。

为什么有的是 10 位,有的是 13 位?

10 位数字以秒为单位,13 位数字则精确到毫秒。

显示的是哪个时区的时间?

同时显示您设备的本地时区时间和 UTC 协调世界时。

指南 · 日期与时间 · 约 3 分钟

Unix 时间戳详解:秒与毫秒、时区和 2038 年问题

1700000000 是什么时候?为什么有些系统用 13 位数字?为什么时间恰好差了 8 个小时?弄懂几个概念,大部分时间相关的 bug 就会消失。

Unix 时间戳(Unix 时间、纪元时间)是一个整数,表示自 1970 年 1 月 1 日 00:00:00 UTC(即 Unix 纪元)以来经过的秒数。0 是 1970-01-01 00:00:00 UTC,1700000000 是 2023-11-14 22:13:20 UTC。

0           → 1970-01-01 00:00:00 UTC
1700000000  → 2023-11-14 22:13:20 UTC
1735689600  → 2025-01-01 00:00:00 UTC
2147483647  → 2038-01-19 03:14:07 UTC
什么是 Unix 时间戳、如何区分 10 位和 13 位数值、UTC 与本地时间的换算、夏令时陷阱以及 2038 年问题。
阅读指南 →
用 AI 自己做

用 AI 亲手打造这个工具

想要自己的版本?把下面的任务提示词粘贴到 AI 聊天中,或将技能文件保存到 AI 编程助手。其中包含我们开发此工具时整理的功能、边界情况和测试用例。

提示词和技能以英文提供,AI 工具在任何语言环境下都能很好地理解。

AI 任务提示词

直接粘贴到 Claude、ChatGPT、Gemini 等 AI 聊天中即可。

You are an experienced full-stack web developer. Build a web tool called "Unix 时间戳转换器" that meets the requirements below.

## Goal

Build a tool that converts between Unix timestamps and human-readable dates.

## Core features

- Timestamp → date and date → timestamp
- Auto-detect seconds (10 digits) or milliseconds (13 digits)
- Show UTC, local and a chosen IANA zone together
- ISO 8601 output
- 'Now' button

## Inputs

- A timestamp or a date and time
- Time zone

## Outputs

- Converted date or timestamp
- ISO 8601 string
- Relative time (e.g. 3 days ago)

## Edge cases and handling rules

- Support negative timestamps before 1970
- Handle values after 2038 correctly
- Explain skipped or repeated local times at DST transitions
- Validate non-numeric input

## Implementation requirements

- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.
- Make the UI responsive and easy to use on mobile; label every input and keep everything keyboard accessible.
- Add a Copy button for results and show clear, friendly error messages for invalid input.
- Keep the core logic in functions separate from the UI so it can be unit-tested.

## Definition of done (test cases)

- 0 → 1970-01-01T00:00:00Z
- 1700000000 → 2023-11-14T22:13:20Z
- 1700000000000 (13 digits) is the same instant

First outline your implementation plan in at most five lines, then write the complete code, and finally explain how to check the test cases above.

技能 (SKILL.md)

在 Claude Code 等 AI 编程助手中保存为 .claude/skills/build-timestamp-converter/SKILL.md,以后开发或修改此工具时可重复使用。

---
name: build-timestamp-converter
description: Use when building or changing a Unix 时间戳转换器 tool. Build a tool that converts between Unix timestamps and human-readable dates.
---

# Build: Unix 时间戳转换器

## Goal

Build a tool that converts between Unix timestamps and human-readable dates.

## Workflow

1. Review the required features, inputs and outputs below and ask about anything missing first.
2. Implement the core logic as pure functions separate from the UI.
3. Check the logic against the test cases in the verification list.
4. Build a responsive UI with an input form, a result area and a Copy button.
5. Reproduce each edge case listed under Rules and refine the error messages.

## Core features

- Timestamp → date and date → timestamp
- Auto-detect seconds (10 digits) or milliseconds (13 digits)
- Show UTC, local and a chosen IANA zone together
- ISO 8601 output
- 'Now' button

## Inputs

- A timestamp or a date and time
- Time zone

## Outputs

- Converted date or timestamp
- ISO 8601 string
- Relative time (e.g. 3 days ago)

## Rules

- Support negative timestamps before 1970
- Handle values after 2038 correctly
- Explain skipped or repeated local times at DST transitions
- Validate non-numeric input
- Build it as a single page (HTML, CSS, JavaScript) that runs entirely in the browser, and never send the user's input to a server.

## Verification

- [ ] 0 → 1970-01-01T00:00:00Z
- [ ] 1700000000 → 2023-11-14T22:13:20Z
- [ ] 1700000000000 (13 digits) is the same instant

交给 AI 时的小技巧

  • 在第一行写明技术栈(如 React、Vue 或纯 HTML),生成的代码会更贴合你的项目。
  • 在接受代码前,请让 AI 运行列出的测试用例并展示结果。
  • 不要把真实密码、客户数据或 API 密钥粘贴到提示词中,请用示例值代替。