我们能作为参数传递给 MySQL UNIX_TIMESTAMP 函数的日期时间值范围是什么?
我们能作为参数传递给 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)
广告