Convert MySQL Timestamp into a Nicer-looking Date Format for PHP

After spending 20 minutes searching online for a way to convert the date stored into MySQL into a human-readable format in php, I thought I would share my solution with the world.

Assuming you’re already doing a foreach or a loop to pull your MySQL variable (in this case, the ($row['timestamp']) below), use the following code:

$date = strtotime($row['timestamp']);
$date = date(’n/d/Y, g:ia’, $date);
echo $date;

Hopefully that will save sometime time.


One Response to “Convert MySQL Timestamp into a Nicer-looking Date Format for PHP”
  1. Gerard Says:

    You could format it in the query using the date_format function. This site shows you how to format the date mysql format date . com

Leave a Reply