如何在不同编程语言中获取现在的Unix时间戳(Unix timestamp)?

2012-03-27  金城  2355

Javatime
JavaScriptMath.round(new Date().getTime()/1000)
getTime()返回数值的单位是毫秒
Microsoft .NET / C#epoch = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000
MySQLSELECT unix_timestamp(now())
Perltime
PHPtime()
PostgreSQLSELECT extract(epoch FROM now())
Pythonimport time然后time.time()
Ruby获取Unix时间戳:Time.nowTime.new
显示Unix时间戳:Time.now.to_i
SQL ServerSELECT DATEDIFF(s,'1970-01-01 00:00:00',GETUTCDATE())
Unix / Linuxdate +%s
VBScript / ASPDateDiff("s","01/01/1970 00:00:00",Now())