我们可以作为MySQL UNIX_TIMESTAMP函数的参数传递的日期时间值的范围与TIMESTAMP数据类型的范围相同,即在'1970-01-01 00:00:01'到'2038-01-19 08之间: 44:07'。如果我们给UNIX_TIMESTAMP函数中的日期时间值超出或低于TIMESTAMP范围,MySQL将返回0作为输出。通过以下示例可以理解-
mysql> select UNIX_TIMESTAMP('2038-01-19 08:44:07'); +---------------------------------------+ | UNIX_TIMESTAMP('2038-01-19 08:44:07') | +---------------------------------------+ | 2147483647 | +---------------------------------------+ 1 row in set (0.00 sec) mysql> select UNIX_TIMESTAMP('2038-01-19 08:44:08'); +---------------------------------------+ | UNIX_TIMESTAMP('2038-01-19 08:44:08') | +---------------------------------------+ | 0 | +---------------------------------------+ 1 row in set (0.00 sec) mysql> select UNIX_TIMESTAMP('1969-01-01 05:10:00'); +---------------------------------------+ | UNIX_TIMESTAMP('1969-01-01 05:10:00') | +---------------------------------------+ | 0 | +---------------------------------------+ 1 row in set (0.00 sec)