0
我目前正在使用PHP和Google的Calendar API从Google日历中提取事件。谷歌的API给出了时间datetime格式:更改日期Google API提取的数据格式
["COURSE_DATE"]=>
string(25) "2014-09-22T06:00:00-04:00"
我想为显示在下面的格式字符串:
date("h:i A");
如何编辑字符串这样只有时间正在显示?
我目前正在使用PHP和Google的Calendar API从Google日历中提取事件。谷歌的API给出了时间datetime格式:更改日期Google API提取的数据格式
["COURSE_DATE"]=>
string(25) "2014-09-22T06:00:00-04:00"
我想为显示在下面的格式字符串:
date("h:i A");
如何编辑字符串这样只有时间正在显示?
您应该首先使用PHP的DateTime解析时间,然后相应地对其进行格式化。
<?php
date_default_timezone_set('America/Toronto'); // If not set already :)
$courseDate = new DateTime('2014-09-22T06:00:00-04:00');
echo $courseDate->format('h:i A');
?>