One of the fields in my database is of 'DATE' Type (field-name = 'post_date').
after fetching an array
$record = mysql_fetch_array($queryResult);
if I do
echo $record['post_date'];
I do not get any output (blank).
What should I do to properly handle the date type?
如果执行此操作后得到的输出为空白(并且查询未中断),则问题在于列值为NULL,而不是PHP交互有任何问题。
This should work. Are you sure the fieldname is right, and that there's data in there?
As an aside: Dates are handled differently in MySQL and PHP:
You can use the MySQL from_unixtime()
and unix_timestamp()
functions to convert back and forth as required.
将MySQL DATE或DATETIME字段解析为UNIX时间戳的最简单方法是使用strtotime 。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.