时间戳转换
Unix时间戳与日期时间互相转换
当前时间戳(实时)
2026-07-05 21:57:26 星期日
秒级1783259846
毫秒级1783259846950
时间戳 → 日期时间
日期时间 → 时间戳
多时区对比
默认时区:
北京时间
GMT+8
2026/07/05 21:57:26
纽约
GMT-4
2026/07/05 09:57:26
| 语言 | 秒级 | 毫秒级 | |
|---|---|---|---|
| JavaScript | Math.floor(Date.now() / 1000) | Date.now() | |
| Python | int(time.time()) | int(time.time() * 1000) | |
| Java | Instant.now().getEpochSecond() | System.currentTimeMillis() | |
| Go | time.Now().Unix() | time.Now().UnixMilli() | |
| PHP | time() | microtime(true) * 1000 | |
| Shell | date +%s | date +%s%3N | |
| MySQL | UNIX_TIMESTAMP(NOW()) | UNIX_TIMESTAMP(NOW()) * 1000 | |
| C# | ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeSeconds() | new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds() | |
| Swift | Int(Date().timeIntervalSince1970) | Int(Date().timeIntervalSince1970 * 1000) | |
| Rust | SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() | ...unwrap().as_millis() |