Home  >  Article  >  Database  >  What does MySQL return when you pass an out-of-range value in the UNIX_TIMESTAMP() or FROM_UNIXTIME() function?

What does MySQL return when you pass an out-of-range value in the UNIX_TIMESTAMP() or FROM_UNIXTIME() function?

WBOY
WBOYforward
2023-08-31 20:01:061341browse

在 UNIX_TIMESTAMP() 或 FROM_UNIXTIME() 函数中传递超出范围的值时,MySQL 将返回什么?

MySQL returns 0 when we pass out-of-range value in UNIX_TIMESTAMP. The valid range of values ​​is the same as the TIMESTAMP data type.

Example

mysql> Select UNIX_TIMESTAMP('1969-01-01 04:05:45');
+---------------------------------------+
| UNIX_TIMESTAMP('1969-01-01 04:05:45') |
+---------------------------------------+
|                         0             |
+---------------------------------------+
1 row in set (0.00 sec)

MySQL returns NULL when we pass an out-of-range value in FROM_UNIXTIME. The valid range of values ​​is the same as the INTEGER data type.

Example

mysql> Select FROM_UNIXTIME(2147483648);
+---------------------------+
| FROM_UNIXTIME(2147483648) |
+---------------------------+
| NULL                      |
+---------------------------+
1 row in set (0.00 sec)

The above is the detailed content of What does MySQL return when you pass an out-of-range value in the UNIX_TIMESTAMP() or FROM_UNIXTIME() function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete