我们可以将哪些日期时间值范围作为参数传递给 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)
广告