Range of Date Time Values for MySQL UNIX_TIMESTAMP Function



The range of date time value that we can pass as an argument to MySQL UNIX_TIMESTAMP function is the same as the range of TIMESTAMP data type i.e. between ‘1970-01-01 00:00:01’ to ‘2038-01-19 08:44:07’. If we give the date time values in UNIX_TIMESTAMP function beyond or below TIMESTAMP range, MySQL will return 0 as output. It can be understood with the help of the following example −

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)
Updated on: 2020-01-30T05:24:36+05:30

169 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements