Syntax
UNIX_TIMESTAMP()
UNIX_TIMESTAMP(date)
Purpose
When you do not specify the
dateparameter, the function returns the number of seconds between the current time and'1970-01-01 00:00:00', taking into account the time zone.When you specify the
dateparameter, the function returns the number of seconds between the specified time and'1970-01-01 00:00:00', taking into account the time zone.
Note
The parameter of this function can be a date or time of the DATE, DATETIME, or TIMESTAMP type.
Examples
obclient> SELECT UNIX_TIMESTAMP(), TIME_TO_USEC(NOW());
+------------------+---------------------+
| UNIX_TIMESTAMP() | TIME_TO_USEC(NOW()) |
+------------------+---------------------+
| 1525570561 | 1525570561000000 |
+------------------+---------------------+
1 row in set
obclient> SELECT UNIX_TIMESTAMP('1997-10-04 22:23:00');
+---------------------------------------+
| UNIX_TIMESTAMP('1997-10-04 22:23:00') |
+---------------------------------------+
| 875974980 |
+---------------------------------------+
1 row in set