在 MySQL 中,我們如何將時間值表示為一個整數?


在 MySQL 中,表示時間值作為整數的方式可以使用 Unix 時間戳格式。日期的整數表示為秒數。用於計算秒數的起始日期為“1970-01-01”。

mysql> SELECT UNIX_TIMESTAMP('2017-10-22 04:05:36')AS 'Total Number of Seconds';
+-------------------------+
| Total Number of Seconds |
+-------------------------+
|              1508625336 |
+-------------------------+
1 row in set (0.00 sec)

UNIX_TIMESTAMP 的值為 10 位數字。

更新於: 30-01-2020

729 次瀏覽

開啟你的 職業生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.