Convert Unix timestamp into human readable date using MySQL
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.
Solution 1:
Use FROM_UNIXTIME()
:
SELECT
FROM_UNIXTIME(timestamp)
FROM
your_table;
See also: MySQL documentation on FROM_UNIXTIME()
.
Solution 2:
What's missing from the other answers (as of this writing) and not directly obvious is that from_unixtime
can take a second parameter to specify the format like so:
SELECT
from_unixtime(timestamp, '%Y %D %M %H:%i:%s')
FROM
your_table
Solution 3:
I think what you're looking for is FROM_UNIXTIME()