Unix时间戳转换

现在:
控制:
时间戳
时间

获取当前时间戳

Java

time

JavaScript

Math.round(new Date() / 1000)

.NET / C#

(DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000

PHP

time()

MySQL

SELECT unix_timestamp(now())

SQL Server

SELECT DATEDIFF(s, '1970-01-01 00:00:00', GETUTCDATE())

SQLite

SELECT strftime('%s', 'now')

PostgreSQL

SELECT extract(epoch FROM now())

Python

先 import time 然后 time.time()

Ruby

获取Unix时间戳:Time.now 或 Time.new显示Unix时间戳:Time.now.to_i

Perl

time

Swift

NSDate().timeIntervalSince1970

Objective-C

[[NSDate date] timeIntervalSince1970]

Erlang

calendar:datetime_to_gregorian_seconds(calendar:universal_time())-719528*24*3600.

Go

import ("time") int32(time.Now().Unix())

Unix / Linux

date +%s

VBScript / ASP

DateDiff("s", "01/01/1970 00:00:00", Now())