Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2023-08-31 20:01:06
forward
1428 people have browsed it

在 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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template