Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
现在我将日期存储在数据库中,格式date("Y-m-d")并将其存储在日期列中。
date("Y-m-d")
现在,我已经从数据库中检索了它,但我怎样才能显示它
October 31st 2010
谢谢!
使用将日期转换为时间戳strtotime并使用date.
strtotime
date
echo date('F jS Y', strtotime($databaseDate));
前进的首选方式应该是使用DateTime该类:
DateTime
date_default_timezone_set('Asia/Tokyo'); $date = new DateTime($databaseDate); echo $date->format('F jS Y');
date_format在您的 SQL 查询中使用。
date_format
例子:date_format(somefield, '%d-%m-%Y, %h:%i %p')
date_format(somefield, '%d-%m-%Y, %h:%i %p')