如何在不同编程语言中获取现在的Unix时间戳(Unixtimestamp)?
@H_403_14@Java |
@H_403_14@time |
@H_403_14@JavaScript |
@H_403_14@Math.round(new Date().getTime()/1000) |
@H_403_14@Microsoft .NET / C# |
@H_403_14@epoch = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000 |
@H_403_14@SELECT unix_timestamp(now()) |
|
@H_403_14@Perl |
@H_403_14@time |
@H_403_14@time() |
|
@H_403_14@SELECT extract(epoch FROM now()) |
|
@H_403_14@Python |
@H_403_14@先import time然后time.time() |
@H_403_14@Ruby |
@H_403_14@获取Unix时间戳:Time.now或Time.new |
@H_403_14@SELECT DATEDIFF(s,'1970-01-01 00:00:00',GETUTCDATE()) |
|
@H_403_14@Unix / Linux |
@H_403_14@date +%s |
@H_403_14@VBScript / ASP |
@H_403_14@DateDiff("s","01/01/1970 00:00:00",Now()) |
@H_403_14@命令行状态:perl -e "print time" |
如何在不同编程语言中实现Unix时间戳(Unixtimestamp) → 普通时间?
@H_403_14@Java |
@H_403_14@String date = @H_403_14@new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new java.util.Date(Unix timestamp* 1000)) |
@H_403_14@JavaScript |
@H_403_14@先var unixTimestamp = @H_403_14@new Date(Unix timestamp* 1000)然后commonTime = unixTimestamp.toLocaleString() |
@H_403_14@Linux |
@H_403_14@date -d @Unix timestamp |
@H_403_14@from_unixtime(Unix timestamp) |
|
@H_403_14@Perl |
@H_403_14@先my $time =Unix timestamp 然后my ($sec,$min,$hour,$day,$month,$year) = (localtime($time))[0,1,2,3,4,5,6] |
@H_403_14@date('r',Unix timestamp) |
|
@H_403_14@SELECT TIMESTAMP WITH TIME ZONE 'epoch' +Unix timestamp) * INTERVAL '1 second'; |
|
@H_403_14@Python |
@H_403_14@先import time然后time.gmtime(Unix timestamp) |
@H_403_14@Ruby |
@H_403_14@Time.at(Unix timestamp) |
@H_403_14@DATEADD(s,Unix timestamp,'1970-01-01 00:00:00') |
|
@H_403_14@VBScript / ASP |
@H_403_14@DateAdd("s","01/01/1970 00:00:00") |
@H_403_14@命令行状态:perl -e "print scalar(localtime(Unix timestamp))" |
如何在不同编程语言中实现普通时间 → Unix时间戳(Unixtimestamp)?
@H_403_14@Java |
@H_403_14@long epoch = @H_403_14@new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").parse("01/01/1970 01:00:00"); |
@H_403_14@JavaScript |
@H_403_14@var commonTime = new Date(Date.UTC(year,month- 1,day,hour,minute,second)) |
@H_403_14@SELECT unix_timestamp(time) |
|
@H_403_14@Perl |
@H_403_14@先use Time::Local然后my $time = timelocal($sec,$year); |
@H_403_14@mktime(hour,second,month,year) |
|
@H_403_14@SELECT extract(epoch FROM date('YYYY-MM-DD HH:MM:SS')); |
|
@H_403_14@Python |
@H_403_14@先import time 然后int(time.mktime(time.strptime('YYYY-MM-DD HH:MM:SS','%Y-%m-%d %H:%M:%S'))) |
@H_403_14@Ruby |
@H_403_14@Time.local(year,second) |
@H_403_14@SELECT DATEDIFF(s,time) |
|
@H_403_14@Unix / Linux |
@H_403_14@date +%s -d"Jan 1,1970 00:00:01" |
@H_403_14@VBScript / ASP |
@H_403_14@DateDiff("s",time) |