我们在开发过程中经常要用到时间戳转换成时间,自己写代码又比较麻烦,所以我开发个能直接在线转换时间戳的工具。
只需要输入时间就能一键转换成时间,还能把时间转换成时间戳。
在线体验地址:https://www.willenyao.com/a/timestamp
语言 | 代码 |
---|---|
Java | time |
JavaScript | Math.round(new Date().getTime()/1000) |
Microsoft .NET / C# | epoch = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000 |
MySQL | SELECT unix_timestamp(now()) |
Perl | time |
PHP | time() |
PostgreSQL | SELECT extract(epoch FROM now()) |
Python | 先 import time 然后 time.time() |
Ruby | 获取Unix时间戳:Time.now 或 Time.new |
Go | 先 import time 然后 int32(time.Now().Unix()) |
SQL Server | SELECT DATEDIFF(s, '1970-01-01 00:00:00', GETUTCDATE()) |
Unix / Linux | date +%s |
VBScript / ASP | DateDiff("s", "01/01/1970 00:00:00", Now()) |
其他操作系统 | 命令行状态:perl -e "print time" |