我在日期时间下面得到了这个字符串。
2013-12-31T00:00:00+01:00
我想将其显示为
2013 年 12 月 31 日凌晨 1 点
请建议我如何使用 php datetime 来实现这一点。
提前致谢。
$dt = new DateTime('2013-12-31T00:00:00+01:00');
echo $dt->format('d/m/Y Ha');
FYI, I voted your question down for showing no effort. This actually is easy to figure out from the docs.
$old_date = '2013-12-31T00:00:00+01:00';
$new_date = date('d/m/Y Ha',strtotime($old_date));
echo $new_date;
这使用了 Date 将日期从一种格式转换为另一种格式的能力