如果不帶參數(shù)調(diào)用,返回一個(gè)Unix時(shí)間戳(自“1970-01-0100:00:00”UTC)作為無符號(hào)整數(shù)。如果UNIX_TIMESTAMP()被調(diào)用有一個(gè)日期參數(shù),它返回的參數(shù)為秒,自“1970-01-0100:00:00”UTC的數(shù)值。日期可能是一個(gè)DATE字符串,一個(gè)DATETIME字符串,一個(gè)TIMESTAMP或數(shù)字格式Y(jié)YYYMMDD或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)