我在格式化從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