时间戳是什么
Unix 时间戳是从 1970-01-01 00:00:00 UTC(纪元,epoch)起经过的秒数或毫秒数。它是一个纯数字的绝对时刻:
0 → 1970-01-01 00:00:00 UTC
1780000000 → 2026-05-29 附近的某秒(秒级)
1780000000000 → 同一时刻(毫秒级)
它不依赖任何时区、任何语言格式——这就是为什么日志、数据库、API 全都用它。
10 位秒 vs 13 位毫秒
| 形式 | 单位 | 典型来源 |
| 1780000000 | 秒 | Unix 传统、系统日志、多数 API |
| 1780000000000 | 毫秒 | JavaScript Date.now()、Java 默认 |
换算就是 ×1000 / ÷1000。本站时间戳工具会按位数自动识别并支持手动覆盖。
时区陷阱
- 时间戳无时区:它是绝对时长;「2026-09-27 14:00」才有时区参与
- 差 8 小时不是 bug:UTC 与北京时间(UTC+8)的固有差异,对表用
- 永远传时间戳,不要传日期字符串:「09/27/2026」在不同地区是不同日期,时间戳没有歧义
- 数据库存 UTC:展示层再转本地,两层混用是时区 bug 的头号来源
ISO 8601 怎么写
2026-09-27T14:00:00Z (Z = UTC,最标准)
2026-09-27T14:00:00+08:00 (带时区偏移)
2026-09-27T14:00:00 ⚠ 无时区——解析端各猜各的,别这么写
规则:给人看用 ISO 8601(必带时区),给机器算用时间戳。
各语言代码速查
// JavaScript(毫秒)
Date.now() // 当前毫秒
new Date(1780000000000) // 毫秒 → Date
Math.floor(ts / 1000) // 毫秒 → 秒
# Python(秒,浮点)
import time; time.time() # 当前秒
from datetime import datetime, timezone
datetime.fromtimestamp(1780000000, tz=timezone.utc)
// Java(毫秒)
System.currentTimeMillis();
Instant.ofEpochSecond(1780000000L); // 秒版
// Go(秒、纳秒)
time.Now().Unix() // 秒
time.Now().UnixMilli() // 毫秒
-- SQL (MySQL)
UNIX_TIMESTAMP() -- 当前秒
FROM_UNIXTIME(1780000000) -- 秒 → datetime
常见问题
Q:为什么同一时间戳在不同时区显示不同日期?
A:时间戳是 UTC 起点的绝对时长,无时区;显示日期时本地时区才参与。跨系统永远传时间戳,展示才本地化。
Q:怎么判断是秒还是毫秒?
A:10 位是秒、13 位是毫秒,两者是 1000 倍关系。
Q:2038 年问题还影响今天的系统吗?
A:只影响 32 位有符号秒级时间戳的老设备(上限 2038-01-19);64 位系统与毫秒时间戳不受影响。
Q:ISO 8601 和时间戳怎么选?
A:人类阅读用 ISO 8601(必带时区后缀);存储、计算、排序用时间戳。
Q:负数时间戳是什么?
A:1970-01-01 UTC 之前的时刻(如 -86400 = 1969-12-31)。生日、历史数据会遇到,个别老系统不支持。
免费在线时间戳转换
当前时间戳实时显示 · 秒/毫秒自动识别 · 本地/UTC/ISO 一次给全 · 纯本地处理
打开时间戳工具 →
What a timestamp is
A Unix timestamp is the number of seconds or milliseconds elapsed since 1970-01-01 00:00:00 UTC (the epoch) — a pure-numeric absolute instant:
0 → 1970-01-01 00:00:00 UTC
1780000000 → some second around 2026-05-29 (seconds)
1780000000000 → the same instant (milliseconds)
It depends on no time zone and no language format — which is why logs, databases, and APIs all use it.
10-digit seconds vs 13-digit ms
| Form | Unit | Typical source |
| 1780000000 | seconds | Unix tradition, system logs, most APIs |
| 1780000000000 | milliseconds | JavaScript Date.now(), Java default |
Conversion is ×1000 / ÷1000. Our Timestamp tool auto-detects by digit count with a manual override.
Time zone traps
- Timestamps have no time zone: they're absolute durations; only rendering as "2026-09-27 14:00" involves a zone
- An 8-hour offset isn't a bug: it's the fixed UTC vs Beijing (UTC+8) difference
- Always pass timestamps, never date strings: "09/27/2026" means different dates in different regions; timestamps are unambiguous
- Store UTC in databases: localize at the display layer — mixing the two is the #1 source of time zone bugs
Writing ISO 8601
2026-09-27T14:00:00Z (Z = UTC, most standard)
2026-09-27T14:00:00+08:00 (with an offset)
2026-09-27T14:00:00 ⚠ no zone — parsers guess, don't do this
Rule: ISO 8601 (with zone) for humans, timestamps for machines.
Per-language snippets
// JavaScript (ms)
Date.now() // current ms
new Date(1780000000000) // ms → Date
Math.floor(ts / 1000) // ms → s
# Python (s, float)
import time; time.time() // current s
from datetime import datetime, timezone
datetime.fromtimestamp(1780000000, tz=timezone.utc)
// Java (ms)
System.currentTimeMillis();
Instant.ofEpochSecond(1780000000L); // seconds
// Go (s, ns)
time.Now().Unix() // seconds
time.Now().UnixMilli() // milliseconds
-- SQL (MySQL)
UNIX_TIMESTAMP() -- current s
FROM_UNIXTIME(1780000000) -- s → datetime
FAQ
Q: Why does the same timestamp show different dates in different zones?
A: Timestamps are absolute from UTC, zone-free; local zones only enter when displaying. Pass timestamps between systems; localize at display.
Q: Seconds or milliseconds?
A: 10 digits = seconds, 13 = milliseconds — a 1000× relationship.
Q: Does the 2038 problem still matter?
A: Only for 32-bit signed second timestamps on legacy devices (capped 2038-01-19); 64-bit systems and ms timestamps are fine.
Q: ISO 8601 or timestamp?
A: ISO 8601 (with zone suffix) for humans; timestamps for storage, computation, and sorting.
Q: What are negative timestamps?
A: Instants before 1970-01-01 UTC (-86400 = 1969-12-31). Relevant for birthdays/history; some legacy systems don't support them.
Free Online Timestamp Converter
Live current timestamp · Auto s/ms detect · Local/UTC/ISO at once · Fully local
Open the Tool →