- Instant help with your Sql coding problems

Convert Unix timestamp to human readable date in MySQL

Question:
How to convert Unix timestamp to human readable date in MySQL?
Answer:
SELECT FROM_UNIXTIME(event_time) AS formattedEventTime FROM events;

-- OR --

SELECT FROM_UNIXTIME(event_time, '%Y-%m-%d') AS isoDate FROM events;
Description:

If you need a human-readable format for a Unix timestamp column in the output of a MySQL query, you can easily do the conversion using the FROM_UNIXTIME() function. 

If you want to get a format other than the default, you can pass a format string as an optional second parameter.

Share "How to convert Unix timestamp to human readable date in MySQL?"