{"id":2495,"date":"2024-04-01T11:21:10","date_gmt":"2024-04-01T03:21:10","guid":{"rendered":"http:\/\/www.plm.cn\/?p=2495"},"modified":"2024-04-01T11:21:10","modified_gmt":"2024-04-01T03:21:10","slug":"%e5%90%84%e7%a7%8d%e7%a8%8b%e5%ba%8f%e5%a4%84%e7%90%86unix%e6%97%b6%e9%97%b4%e6%88%b3%ef%bc%88unix-timestamp%ef%bc%89%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"http:\/\/www.plm.cn\/2495\/","title":{"rendered":"\u5404\u79cd\u7a0b\u5e8f\u5904\u7406Unix\u65f6\u95f4\u6233\uff08Unix timestamp\uff09\u65b9\u6cd5"},"content":{"rendered":"

\u7f16\u7a0b\u7a0b\u5e8f\u83b7\u53d6\u5f53\u524d\u65f6\u95f4Unix\u65f6\u95f4\u6233\uff08Unix timestamp\uff09\u65b9\u6cd5<\/h3>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Java<\/td>\ntime<\/td>\n<\/tr>\n
JavaScript<\/td>\nMath.round(new Date().getTime()\/1000)<\/td>\n<\/tr>\n
getTime()\u8fd4\u56de\u6570\u503c\u7684\u5355\u4f4d\u662f\u6beb\u79d2<\/td>\n<\/tr>\n
Unix \/ Linux<\/td>\ndate +%s<\/td>\n<\/tr>\n
Microsoft .NET \/ C#<\/td>\nepoch = (DateTime.Now.ToUniversalTime().Ticks – 621355968000000000) \/ 10000000<\/td>\n<\/tr>\n
Python<\/td>\n1\uff09 import time\u00a0 \u00a0 2\uff09 time.time()<\/td>\n<\/tr>\n
Perl<\/td>\ntime<\/td>\n<\/tr>\n
PHP<\/td>\ntime()<\/td>\n<\/tr>\n
MySQL<\/td>\nSELECT unix_timestamp(now())<\/td>\n<\/tr>\n
PostgreSQL<\/td>\nSELECT extract(epoch FROM now())<\/td>\n<\/tr>\n
SQL Server<\/td>\nSELECT DATEDIFF(s, ‘1970-01-01 00:00:00’, GETUTCDATE())<\/td>\n<\/tr>\n
Ruby<\/td>\n\u83b7\u53d6 Unix\u65f6\u95f4\u6233\uff1aTime.now\u00a0 \u00a0 or\u00a0 \u00a0Time.new<\/td>\n<\/tr>\n
\u663e\u793a Unix\u65f6\u95f4\u6233\uff1aTime.now.to_i<\/td>\n<\/tr>\n
VBScript \/ ASP<\/td>\nDateDiff(“s”, “01\/01\/1970 00:00:00”, Now())<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

 <\/p>\n

\u7f16\u7a0b\u7a0b\u5e8f\u8d4b\u503c\u65f6\u95f4\u53d8\u91cf\u4e3aUnix\u65f6\u95f4\u6233\uff08Unix timestamp\uff09\u65b9\u6cd5<\/h3>\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Java<\/td>\nString date = new java.text.SimpleDateFormat(“dd\/MM\/yyyy HH:mm:ss”).format(new java.util.Date(Unix timestamp * 1000))<\/td>\n<\/tr>\n
JavaScript<\/td>\n\u5148 var unixTimestamp = new Date(Unix timestamp * 1000) \u7136\u540e commonTime = unixTimestamp.toLocaleString()<\/td>\n<\/tr>\n
Linux<\/td>\ndate -d @Unix timestamp<\/td>\n<\/tr>\n
Perl<\/td>\n1\uff09my $time = Unix timestamp\u00a0 2\uff09my ($sec, $min, $hour, $day, $month, $year) = (localtime($time))[0,1,2,3,4,5,6]<\/td>\n<\/tr>\n
PHP<\/td>\ndate(‘r’, Unix timestamp)<\/td>\n<\/tr>\n
MySQL<\/td>\nfrom_unixtime(Unix timestamp)<\/td>\n<\/tr>\n
PostgreSQL<\/td>\nSELECT TIMESTAMP WITH TIME ZONE ‘epoch’ + Unix timestamp) * INTERVAL ‘1 second’;<\/td>\n<\/tr>\n
Python<\/td>\n1\uff09 import time\u00a0 \u00a0 2\uff09 time.gmtime(Unix timestamp)<\/td>\n<\/tr>\n
SQL Server<\/td>\nDATEADD(s, Unix timestamp, ‘1970-01-01 00:00:00’)<\/td>\n<\/tr>\n
Ruby<\/td>\nTime.at(Unix timestamp)<\/td>\n<\/tr>\n
VBScript \/ ASP<\/td>\nDateAdd(“s”, Unix timestamp, “01\/01\/1970 00:00:00”)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"

\u7f16\u7a0b\u7a0b\u5e8f\u83b7\u53d6\u5f53\u524d\u65f6\u95f4Unix\u65f6\u95f4\u6233\uff08Unix timestamp\uff09\u65b9\u6cd5 Java time JavaScrip […]<\/p>\n","protected":false},"author":1,"featured_media":2496,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[16],"class_list":["post-2495","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","tag-xinwen"],"_links":{"self":[{"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/posts\/2495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/comments?post=2495"}],"version-history":[{"count":1,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/posts\/2495\/revisions"}],"predecessor-version":[{"id":2497,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/posts\/2495\/revisions\/2497"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/media\/2496"}],"wp:attachment":[{"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/media?parent=2495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/categories?post=2495"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.plm.cn\/wp-json\/wp\/v2\/tags?post=2495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}