Skip to main content
Version: V1.0.0

UNIX_TIMESTAMP

Syntax

UNIX_TIMESTAMP()
UNIX_TIMESTAMP(date)

Description

  • If you do not specify the date parameter, it returns the number of seconds between the current time and '1970-01-01 00:00:00', considering the time zone.

  • If you specify the date parameter, it returns the number of seconds between the specified time and '1970-01-01 00:00:00', considering the time zone.

info

The parameter of this function can be a date or time of the DATE, DATETIME, or TIMESTAMP type.

Examples

SELECT UNIX_TIMESTAMP(), TIME_TO_USEC(NOW());
+------------------+---------------------+
| UNIX_TIMESTAMP() | TIME_TO_USEC(NOW()) |
+------------------+---------------------+
| 1525570561 | 1525570561000000 |
+------------------+---------------------+
1 row in set (0.001 sec)

SELECT UNIX_TIMESTAMP('1997-10-04 22:23:00');
+---------------------------------------+
| UNIX_TIMESTAMP('1997-10-04 22:23:00') |
+---------------------------------------+
| 875974980 |
+---------------------------------------+
1 row in set (0.001 sec)