我在格式化从MySQL数据库接收到的日期时遇到问题。我不断收到此错误:PHP中的日期格式
Notice: A non well formed numeric value encountered in C:\xampp\htdocs\index.php on line 23
这里是我的代码:
$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>";
}
我已经阅读过的时间戳PHP手册和日期功能,我似乎无法找出我的问题是。
哪一行是第23行?赔率是'$ news_data ['date']'不是你认为的那样。 – j08691 2012-03-24 18:30:49
mysql表中'date'的数据类型是什么? – safarov 2012-03-24 18:30:57
第23行是这样的:$ date = date(“M d,Y - g:i:s A”,$ news_data ['date']);该类型是使用CURRENT_TIMESTAMP的时间戳。 – legobear154 2012-03-24 18:31:40