I'm having a couple of problems with the DATEFORMAT mysql function.
My database looks similar to:
PostID | TopicID | ForumID | PostAuthor | PostDate | PostIP | PostTitle | PostMsg |
PostDate is TIMESTAMP(14)
I'm trying to show the date on screen in a format similar to:
'Tues 2 Dec 2003 - 11:30 am'
But i couldn't get it to work 🙁
// Get Latest Post In Forum
$var['temp']['latest_post'] = @mysql_query("SELECT * FROM $db_posts_table WHERE(ForumID = {$row['ForumID']}) ORDER BY PostDate DESC");
$var['temp']['latest_post2'] = @mysql_num_rows($var['temp']['latest_post']);
if($var['temp']['latest_post2'] == 0){
$var['temp']['latest_post'] = "Currently No Posts";
}
else{
$temp = mysql_fetch_array($var['temp']['latest_post']);
$var['temp']['latest_post'] = $temp['PostDate'] . "<BR>By " . $temp['PostAuthor'];
}
But the date kept getting displayed as '20040117152856'
I tried something similar to:
// Get Latest Post In Forum
$var['temp']['latest_post'] = @mysql_query("SELECT PostAuthor, DATEFORMAT('%a %b %Y - %h:%i',PostDate) AS PostDate FROM $db_posts_table WHERE(ForumID = {$row['ForumID']}) ORDER BY PostDate DESC");
$var['temp']['latest_post2'] = @mysql_num_rows($var['temp']['latest_post']);
if($var['temp']['latest_post2'] == 0){
$var['temp']['latest_post'] = "Currently No Posts";
}
else{
$temp = mysql_fetch_array($var['temp']['latest_post']);
$var['temp']['latest_post'] = $temp['PostDate'] . "<BR>By " . $temp['PostAuthor'];
}
Any help would be appreciated 😃
Thanks