UNIX_TIMESTAMP()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a time as a number of seconds since the Unix epoch began.
USAGE
UNIX_TIMESTAMP([timestamp])
Argument Name | Description |
---|---|
| A date value or date-time value |
DETAILS
UNIX_TIMESTAMP()
is a date-time function that returns a time measured in seconds since the start of the Unix epoch, which is '1970-01-01 00:00:00' UTC.
When called with the optional timestamp
argument, the time returned is for the given timestamp instead of returning the current time. The return is also turned into a floating-point value number.
A NULL
is returned if the argument is NULL
.
EXAMPLES
SELECT UNIX_TIMESTAMP(), UNIX_TIMESTAMP(NOW());
+------------------+-----------------------+
| UNIX_TIMESTAMP() | UNIX_TIMESTAMP(NOW()) |
+------------------+-----------------------+
| 1604630731 | 1604630731.000000 |
+------------------+-----------------------+
SELECT UNIX_TIMESTAMP('2020-02-01 01:30:59') AS result1,
UNIX_TIMESTAMP('2020-02-01') AS result2;
+-------------------+-------------------+
| result1 | result2 |
+-------------------+-------------------+
| 1580520659.000000 | 1580515200.000000 |
+-------------------+-------------------+