View Full Version : converting DATETIME using strtotime()

07-23-2008, 05:40 PM
I am trying to convert '2008-07-19 04:10:47' into day month year format for a review table but keep getting an error.

Here is my code

$date = strtotime($row['dateCreated']);
$ratingTable= $ratingTable. "<tr><td>" . date(d F Y, $date) . "</td></tr>";

I can't see anything wrong but am getting an ENCAPSED_AND_WHITESPACE error. Can anyone help please ?

07-23-2008, 05:43 PM

$date = strtotime($row['dateCreated']);
$ratingTable= $ratingTable. "<tr><td>" . date("d F Y", $date) . "</td></tr>";

The formatting specification for date needs to be enclosed in quotes.

07-23-2008, 05:50 PM
Thanks, it's so obvious when someone points it out.

07-23-2008, 06:00 PM
It's also worth noting that using $date as a variable name may result in confusion. You could put the conversion "in-line" and save a variable assignment in the process.

$ratingTable= $ratingTable. "<tr><td>" . date("d F Y", strtotime($row['dateCreated'])) . "</td></tr>";

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum