从数据库PHP显示日期

问题描述:

现在我以date("Y-m-d")格式将日期存储在数据库中,并即时将其存储在

right now I'm storing a date in the database, in the format date("Y-m-d") and im storing it in date column.

现在,我已经从数据库中检索了它,但是如何显示它

Now, I've retrieved it from the database but how can i display it like

October 31st 2010

谢谢!

将日期转换为时间戳使用 strtotime 并使用

Convert the date to a timestamp using strtotime and format it using date.

echo date('F jS Y', strtotime($databaseDate));

最好的前进方式应该是使用 DateTime 类别:

The preferred way going forward should be the use of the DateTime class though:

date_default_timezone_set('Asia/Tokyo');

$date = new DateTime($databaseDate);
echo $date->format('F jS Y');