Convert an Epoch date to Readable date in MySQL

Basic format

SELECT FROM_UNIXTIME(epoch) as value FROM mytable

Will display in the format like

2012-01-18 05:28:03

Or if you want to format the date specifically

SELECT FROM_UNIXTIME(epoch,"%Y-%m-%d") as value FROM mytable

Or to insert into a table


or use YYYY-MM-DD HH:MM:SS :

INSERT INTO mytable VALUES (UNIX_TIMESTAMP('2008-12-01 12:00:00'))

Check out the Epoch Converter for more info.

Leave a comment

Your email address will not be published. Required fields are marked *