[MySQL] Convert a Unix timestamp to a date and time

Created on November 30, 2026

You can use FROM_UNIXTIME() to convert Unix seconds to a date and time in the current MySQL session's time zone. The example sets the time zone to UTC for the session before converting the timestamp.

SET time_zone = '+00:00';
SELECT FROM_UNIXTIME(1600101541) AS converted_time;
+---------------------+
| converted_time      |
+---------------------+
| 2020-09-14 16:39:01 |
+---------------------+

You can pass a format string as the second argument to return a string such as 2020-09-14.

SELECT FROM_UNIXTIME(1600101541, '%Y-%m-%d') AS calendar_date;
MySQL