Declaration
UNIX_TIMESTAMP()
UNIX_TIMESTAMP(date)
Description
If the
dateparameter is not specified, the number of seconds elapsed from the current time to'1970-01-01 00:00:00'is returned. Time zone information must be taken into account.When the
dateparameter is specified, it returns the number of seconds elapsed from'1970-01-01 00:00:00'up to the specified time. Time zone information must be taken into account.
Note
The parameters of this function can be dates or times 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