In my MySQL table, I have a timestamp column with values like “2008-05-28 00:39:40”. First, I must remove all the formatting:

$delimeters = array('-', ' ', ':');
$time = str_replace($delimeters, '', $new['time']);
echo $time;
// 20080528003940 is displayed

Then I attempt to use the date function on this, but it gives me a weird date in the future:

echo date('M, j, Y', $time);
// Jan, 19, 2038 is displayed

The second parameter is interpreted as the number of seconds since the Unix epoch, I think.

You could use strtotime:

$str = "2008-05-28 00:39:40";
echo date('M, j, Y', strtotime($str));

You need to use php’s strtotime to convert the mysql time to unix time.

$time = strtotime($new['time'];
echo date('M, j, Y', $time);

Yup, that does the trick. Thanks.