SQL UNIX_TIMESTAMP()函數
UNIX_TIMESTAMP(), UNIX_TIMESTAMP(date)
如果不帶參數調用,返回一個Unix時間戳(自「1970-01-0100:00:00」UTC)作爲無符號整數。如果UNIX_TIMESTAMP()被調用有一個日期參數,它返回的參數爲秒,自「1970-01-0100:00:00」UTC的數值。日期可能是一個DATE字符串,一個DATETIME字符串,一個TIMESTAMP或數字格式YYYYMMDD或YYYYMMDD。
mysql> SELECT UNIX_TIMESTAMP(); +---------------------------------------------------------+ | UNIX_TIMESTAMP() | +---------------------------------------------------------+ | 882226357 | +---------------------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT UNIX_TIMESTAMP('1997-10-04 22:23:00'); +---------------------------------------------------------+ | UNIX_TIMESTAMP('1997-10-04 22:23:00') | +---------------------------------------------------------+ | 875996580 | +---------------------------------------------------------+ 1 row in set (0.00 sec)