Unix Timestamp Converter

One input per line. Output is numbered to match the input order.
Pinned tools are listed in your favourites on the home page.Copies a link to this tool that carries your current input, so it opens ready to run.Gives you an iframe snippet for putting this tool on your own site.
Current Unix timestamp: 1785997352
Ctrl+Enter Run  · Ctrl+Shift+C Copy  · Esc Clear

Understand Unix Timestamp Converter

把 Unix 时间戳转换成可读日期并可逆转,同时自动识别该数字的单位是秒还是毫秒。

How it works

Unix 时间是自纪元 1970-01-01T00:00:00Z 起经过的秒数计数。由于它锚定在 UTC 且不携带时区,它在任何地方都无歧义——同一个整数在东京和芝加哥指的是同一时刻,这正是数据库、日志和 API 存储它的原因。JavaScript 计的是毫秒而非秒,因此 JS 的值大一千倍,一个常见的换算 bug 就是得到 1970 年的日期(该乘却除了),或者 55000 年(反过来了)。本工具把大于 1e12 的值当作毫秒,其余都当作秒。

When to use it

  • 从 JWT 中读取 `iat`、`exp` 或 `nbf` 声明,或从数据库行中读取 `created_at` 整数
  • 检查一个「本该有效」的令牌过期时间是否其实已经过去
  • 把日志行的时间戳转成可与部署或故障时刻对照的挂钟时间
  • 产生一个固定的 epoch 值粘进测试夹具,让测试不依赖当前时间

Watch out for

  • 2038 年问题真实存在且已经不远。有符号 32 位秒计数器会在 2038-01-19T03:14:07Z 溢出并回绕到 1901 年——嵌入式系统、老旧 C 代码和某些数据库列至今仍在用它。
  • 秒与毫秒的启发式判断有边界情况。2001 年 9 月之前的毫秒时间戳小于 1e12,会被当成秒读取,得到一个几万年之后的日期。若年份看起来荒谬,请检查单位。
  • Unix 时间按定义忽略闰秒。在闰秒期间同一个值会被使用两次,因此 Unix 时间戳并不是自 1970 年以来真正流逝的 SI 秒数——它是天数乘以 86,400 再加上当天已过的秒数。
  • 负数时间戳是合法的,表示 1970 年之前的日期。不少解析器、电子表格和 ORM 会拒绝或弄错它们。

Frequently Asked Questions

epoch 时间是什么?

epoch 时间(或称 Unix 时间)是自 Unix 纪元 1970 年 1 月 1 日 00:00:00 UTC 以来经过的秒数。它与时区无关,因此成为跨系统、跨编程语言存储、比较和传输时间的通用格式。

Unix 时间戳是什么?

Unix 时间戳是一个整数,表示自 1970 年 1 月 1 日 UTC 以来的秒数(在 JavaScript 中是毫秒数)。数据库和 API 使用它,是因为它紧凑、无歧义且排序正确。10 位数字是秒,13 位是毫秒。

如何把 Unix 时间戳转换成日期?

把时间戳粘进输入框——工具会自动识别是秒还是毫秒,并显示对应的 UTC 与本地日期时间。在 JavaScript 中:new Date(timestamp * 1000).toISOString()。在 Python 中:datetime.fromtimestamp(ts, tz=timezone.utc)。

How to Use Unix Timestamp Converter

  1. Paste or type your input in the input area above.
  2. The tool processes your input automatically or click Run.
  3. Copy or download the result using the action buttons.
  4. Use Ctrl+Enter to run quickly from the keyboard.