返回工具列表
Unix时间戳工具
在线时间戳转换工具,帮助您精确转换时间戳为日期时间或者日期时间为时间戳。
当前时间
当前时间戳(秒)
—
当前时间戳(毫秒)
—
当前日期时间
—
刷新
时间戳 → 日期时间
支持 10 位(秒)或 13 位(毫秒)整数;可含空格。
日期时间 → 时间戳
按本机时区解析;结果含秒与毫秒时间戳。
什么是时间戳?
Unix 时间戳(Unix timestamp)从协调世界时 1970-01-01 00:00:00 UTC 起至某一时刻的累计秒数(常用 10 位);毫秒时间戳为 13 位,广泛用于 JavaScript(Date.now())等场景。
多数系统以 32 位有符号整数保存秒级时间戳,可能在 2038-01-19 附近遇到「Y2038」问题;新系统建议 64 位或毫秒级。
各语言获取当前 Unix 时间戳(示例)
| 语言 | 代码示例 |
|---|---|
| PHP | $timestamp = time(); |
| JavaScript | const s = Math.floor(Date.now() / 1000); const ms = Date.now(); |
| Python | import time; timestamp = int(time.time()) |
| Java | long s = System.currentTimeMillis() / 1000; |
| C# | long s = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); |
| Go | timestamp := time.Now().Unix() |
| Rust | std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_secs() |
| Bash | timestamp=$(date +%s) |