我需要将此(2015-09-30 05:47:58
)时间格式转换为ISO 8601格式,我已尝试使用Google搜索和大量代码示例,但没有运气,API的最终格式为2015-09-30T07:06:21.5663224Z
,感谢帮助< / p>
$date = new DateTime();
echo $new_date = $date->setISODate($order->getPickupDate());
echo $PickupDate = $date->format(DateTime::ATOM);
我想要YYYY-MM-ddTHH:mm:ss.fffffff-HH:MM
答案 0 :(得分:0)
简单使用php的日期功能
date("Y-m-d H:i:s h:i A",strtotime($order->getPickupDate()));
答案 1 :(得分:0)
试试这个
function getTime($timestamp) {
return date ( 'Y-m-d\TH:i:s' . substr ( ( string ) microtime (), 1, 8 ) . ' P', $timestamp ); //instead of P use \Z if zulu time needed UTC.
}
$date = new DateTime ();
//$date->setTimezone(new DateTimeZone("UTC"));
$timestamp = $date->getTimestamp ();
echo getTime ( $timestamp );