...

View Full Version : converting DATETIME using strtotime()



simonwraight
07-23-2008, 05:40 PM
Hi,
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 ?

djm0219
07-23-2008, 05:43 PM
Try:



$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.

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

djm0219
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