Name
FROM_UNIXTIME( )
Synopsis
FROM_UNIXTIME(unix_timestamp
[,format
])
This
function returns the date based on Unix time, which is the number of
seconds since January 1, 1970, Greenwich Mean Time (GMT), with
12:00:01 being the first second of Unix time (the epoch). Optionally
the results may be formatted using the formatting codes from
DATE_FORMAT( )
. It will return the date and time
in a yyyy-mm-dd hh:mm:ss format, but will return
the data in a yyyymmdd format if
it’s used as part of a numeric calculation.
SELECT FROM_UNIXTIME(0) AS 'My Epoch Start'; +----------------------+ | My Epoch Start | +----------------------+ | 1969-12-31 18:00:00 | +----------------------+
Here we’re selecting
the date based on zero seconds since the start of Unix time. The
results are off by six hours because I’m not located
in the GMT zone. This function is typically used on columns in which
their values were derived from UNIXTIME_STAMP( )
.
Get MySQL in a Nutshell 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.