GuerillaRadio
GuerillaRadio

Reputation: 1297

Formatting Time in PHP/MySql

I want to format the date from a MySql result in this format (the code is what i have used elsewhere on the website, not the actual code I have attempted to use, I just want this format)...

date("j F, Y", strtotime($result['comm_date']));

I've done it elsewhere on the site but can't figure out how to format the following result. It is part of a for loop with $str_comments eventually getting echoed to display a list of comments with the username and date of the comment.

$str_comments .= "<span class='comment'>" . mysql_result($result, $j, 'comment') . "</span>";
$str_comments .= " by " . mysql_result($result, $j, 'username');
$str_comments .= " on " . mysql_result($result, $j, 'comm_date') . "</br><br/>";

Any pointers would be much appreciated.

Upvotes: 1

Views: 114

Answers (1)

Petah
Petah

Reputation: 46060

Should it not just be:

$str_comments .= "<span class='comment'>" . mysql_result($result, $j, 'comment') . "</span>";
$str_comments .= " by " . mysql_result($result, $j, 'username');
$str_comments .= " on " . date("j F, Y", strtotime(mysql_result($result, $j, 'comm_date'))) . "</br><br/>";

Upvotes: 1

Related Questions