Unix Time: convert to a readable format

Published by

Posted on April 23, 2012

ever perform a mysql query and the date column returns 1334349567

 

The number in the database is a “unix time”, aka timestamp – seehttp://en.wikipedia.org/wiki/Unix_time

You can convert this to a string using a PHP function like date() http://php.net/date – pass the timestamp as the second parameter.

Eg:

<?php
echo date('Y-m-d H:i:s', 1334349567);
?>;

Check out the other related functions at http://php.net/manual/en/ref.datetime.php