MySQL 8.1
FROM_UNIXTIME(unix_timestamp[, format])- [ ]optional part
- unix_timestamp
- Number of seconds since 1970-01-01 00:00:00 UTCINT
- format
- Format of the result, specifiers as in DATE_FORMATVARCHAROptional
Return value
A datetime in the session time zone, or a string with format; NULL for a negative number
Examples
Date from a number of seconds
MySQL 8.1
SELECT FROM_UNIXTIME(1717588800);Result in a custom format
MySQL 8.1
SELECT FROM_UNIXTIME(1717588800, '%d.%m.%Y %H:%i') AS formatted;Details
The result is shown in the session time zone, so the same number gives different times on servers with different settings. A fractional number gives a date with fractional seconds: FROM_UNIXTIME(1717588800.5). The reverse conversion is done by UNIX_TIMESTAMP.