I have a timestamp from the mySQL database and I would like to format it.
$date = $row['date'];
$date = date("F j, Y, g:i a");
My problem is now that it prints not the date of the database. Instead it prints out the current date. But this is not what I need.
So if I print this, I get the right date:
printf($row['date']);
But if I print this I get the right format but not the right date:
printf($date);
You need to pass that date, as a Unix timestamp, to
date()
as the second parameter. Otherwisedate()
has no idea you want to format a specific date:This assumes that
$row['date']
is in a valid date format.