I have a stored time_stamp in a table and I want to format it from the YYYY-MM-DD HH-MM-SS to show up as Oct 19th 2011.
I’m a bit new at this, but I’m thinking I need to set a new variable that takes that time_stamp and convert it.
$mydate = DATEFORMAT(columnName, %b-%D-%Y);
Its not quite working for me am I on the right track?
Thanks folks
I got the date thing correct now I think.. its just not showing the date. I’ve got a loop that goes through each row till there are no more:
$query = "SELECT comment, DATE_FORMAT(postdate, '%b %D %Y') FROM sessionscomments WHERE session = 'Geoarge'";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
echo "<div id=fav>";
echo strip_tags( "Date: {$row['postdate']}");
So do I still need to make my formatted date into a variable so that it will format it with each row?
If you want to do the formatting in an SQL query, you can use the DATE_FORMAT() function in MySQL.
Formatting the date in PHP, you’ll want to use the date() function in PHP.