what's the raw value of $row['date_posted']
? Remember that date()
expects a PHP timestamp, which is a plain unix timestamp - integer representing seconds since Jan 1/1970. If you feed it a string (e.g. 2012-12-11 08:55:00
, you'll just get a mangled value out, as PHP tries to convert that string to an int:
$now = '2012-12-11 08:56:00';
echo date('r', $now); // Wed, 31 Dec 1969 18:33:32 -0600
echo date('r', (int)$now); // Wed, 31 Dec 1969 18:33:32 -0600
echo (int)$now; // 2012
echo date('r', 2012); // Wed, 31 Dec 1969 18:33:32 -0600
You'll have to convert your date field to a unix timestamp in MySQL, or use MySQL's own date formatting functions:
SELECT UNIX_TIMESTAMP(date_posted), ...
or
SELECT DATE_FORMAT(date_posted, 'format string here'), ...