誰能用簡單明瞭的語言解釋一下什麼是“時間戳”?
作者:由 Dion 發表于 收藏時間:2012-10-30
不要被「戳」嚇到了,就是一個表示當前時間的數字。
「時間戳」這個名字的來源於 Timestamp,為什麼是 stamp 郵戳呢?
看下圖:
在計算機中,「時間戳」一般是指 Unix 時間戳,即自從 Unix 紀元(格林威治時間 1970 年 1 月 1 日 00:00:00)到當前時間的秒數。
常見的程式語言都提供了相關的 API 用於獲取系統時間戳,以下供參考:
Java - System。currentTimeMillis()/1000
PHP - time()
JavaScript - Math。round(new Date()。getTime()/1000)
C# - (DateTime。Now。ToUniversalTime()。Ticks - 621355968000000000) / 10000000
MySQL - SELECT unix_timestamp(now())
Perl - time
Ruby - Time。now 或 Time。new
更多參考:
http://
tool。chinaz。com/Tools/u
nixtime。aspx