时间戳转换器
Unix时间戳转换
如何使用时间戳转换器
- 当前时间戳会按秒或毫秒自动刷新,可暂停或手动刷新。
- 将 Unix 时间戳转为北京时间,或把北京时间转为时间戳,单位可选秒或毫秒。
- 全部在浏览器本地完成。
带时区的时间戳请访问 时间戳在线转换工具。
在编程语言中获取 Unix 时间戳
| 语言 | 秒 | 毫秒 |
|---|---|---|
| JavaScript | Math.round(new Date() / 1000) | new Date().getTime() |
| Java | System.currentTimeMillis() / 1000 | System.currentTimeMillis() |
| Python | int(time.time()) | int(time.time() * 1000) |
| Go | time.Now().Unix() | time.Now().UnixNano() / 1e6 |
| PHP | time() | (int)(microtime(true) * 1000) |
| Ruby | Time.now.to_i | (Time.now.to_f * 1000).to_i |
| C# | DateTimeOffset.UtcNow.ToUnixTimeSeconds() | DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() |
| Swift | NSDate().timeIntervalSince1970 | NSDate().timeIntervalSince1970 * 1000 |
| Objective-C | [[NSDate date] timeIntervalSince1970] | [[NSDate date] timeIntervalSince1970] * 1000 |