- 10
- 0
- 约2.35千字
- 约 2页
- 2021-11-14 发布于江苏
- 举报
时间戳转换
如何在不同编程语言中获取现在的 Unix 时间戳(Unix timestamp)?
Java
Java
time
JavaScript
Math.round(new Date().getTime()/1000)
getTime()返回数值的单位是毫秒
Microsoft .NET / C#
epoch = (DateTime.Now.ToUniversalTime().Ticks - /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
显示 Unix 时间戳:Time.now.to_i
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被安装在系统中)
命令行状态:
原创力文档

文档评论(0)