Name

FROM_UNIXTIME()

Synopsis

FROM_UNIXTIME(unix_timestamp [, format])

Returns the unix_timestamp parameter as a string in either YYY-MM-DD, HH:MM:SS, or YYYMMDDHHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context. If the optional format parameter is provided, the result is formatted according to the specifiers in Table 8-11. This code returns the strings “2000-01-01 00:00:00” and “Saturday January 1st 2000 12:00 AM”:

SELECT FROM_UNIXTIME(946684800);
SELECT FROM_UNIXTIME(946684800, '%W %M %D %Y %h:%i %p');

Get Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.