各种编程开发语言实现 UNIX 时间戳

180it 2022-03-13 AM 687℃ 0条

实现 UNIX 时间戳
语言 代码

JAVA    String date = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new java.util.Date(Unix timestamp *1000))
Linux    date -d @Unix timestamp
C    strptime(datetime, "%Y-%m-%d %H:%M:%S", &tm_time); unixtime = mktime(&tm_time);
C++    std::time_t t = std::time(0);
DELPHI    uses DateUtils;
DateTimeToUnix(Now)
GO    import "time"
cur := time.Now()
timestamp := cur.UnixNano() / 1000000
Perl    先 my $time = Unix timestamp 然后 my ($sec, $min, $hour, $day, $month, $year) = (localtime($time))[0,1,2,3,4,5,6]
PHP    date('r', Unix timestamp)
Node.js    var date = new Date( time * 1000 );
var time = date.getTime()/1000;
Python    先 import time 然后 time.gmtime(Unix timestamp)
Ruby    Time.at(Unix timestamp)
SHELL    date +%s //UNIX 的时间戳;
VBScript / ASP    DateAdd("s", Unix timestamp, "01/01/1970 00:00:00")
VB6    DateDiff("s", "1970-1-1 0:0:0", ToUnixTime)
易语言    时间_到时间戳()
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

各种编程开发语言实现 UNIX 时间戳