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.
Reference:
FROM_UNIXTIME() reference
Share "How to convert Unix timestamp to human readable date in MySQL?"
Related snippets:
- Convert Unix timestamp to human readable date in MySQL
- Count total rows by year in MySQL
- Convert INT to DATETIME in MySQL
- Select year from a Unix timestamp in MySQL
- Group by year of Unix timestamp in MySQL
- Get current year in MySQL
- Extract year from a date in MySQL
- Get current date in MySQL
- Get last 30 days records in MySQL
Tags:
convert, unix timestamp, human readable, date, mysql, int, integer, datetime Technical term:
Convert Unix timestamp to human readable date in MySQL