I am having a problem with formatting a date that I receive from a MySQL database. I keep getting this error:
Notice: A non well formed numeric value encountered in C:\xampp\htdocs\index.php on line 23
Here is my code:
$news_query = $database->query("SELECT * FROM " . DB_NEWS . " ORDER BY 'date'");
while($news_data = mysql_fetch_array($news_query,MYSQL_ASSOC)){
$date = date("M d, Y - g:i:s A", $news_data['date']);
echo "
<DIV class = 'news_post'>
<DIV class = 'news_title'>" . $news_data['title'] . "</DIV>
<DIV class = 'news_info'>Posted on " . $date . " By " . $news_data["author"] . "</DIV>
<DIV class = 'entry'>" . $news_data['entry'] . "</DIV>
</DIV>";
}
I have read over the PHP manual for timestamps and the date function and I can’t seem to figure out what my problem is.
Are you using datetime format in MySQL?
Try this: