FROM_UNIXTIME

2025-11-19 10:08:12  Updated

Syntax

FROM_UNIXTIME(unix_timestamp)
FROM_UNIXTIME(unix_timestamp, format)

Purpose

FROM_UNIXTIME() returns a value based on the following rules:

  • If format is not specified, a value of the DATETIME type is returned, regardless of the time zone.

  • If format is specified, a date and time string in the specified format is returned.

unix_timestamp refers to the UNIX timestamp, that is, the number of seconds from 1970-01-01 00:00:00.

For more information about the formats supported by format, see DATE_FORMAT.

Examples

obclient> SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y %D %M %h:%i:%s %x');
+---------------------------------------------------------+
| FROM_UNIXTIME(UNIX_TIMESTAMP(), '%Y %D %M %h:%i:%s %x') |
+---------------------------------------------------------+
| 2018 5th May 08:41:26 2018                              |
+---------------------------------------------------------+
1 row in set

Contact Us