Convert Unix timestamp into human readable date using MySQL

King Julien picture King Julien · Jun 7, 2011 · Viewed 323.9k times · Source

Is there a MySQL function which can be used to convert a Unix timestamp into a human readable date? I have one field where I save Unix times and now I want to add another field for human readable dates.

Answer

CristiC picture CristiC · Jun 7, 2011

Use FROM_UNIXTIME():

SELECT
  FROM_UNIXTIME(timestamp) 
FROM 
  your_table;

See also: MySQL documentation on FROM_UNIXTIME().