php新日期时间和gmdate
如何转换以下内容,使其使用 这部分很简单,但是日期呢php新日期时间和gmdate,php,Php,如何转换以下内容,使其使用 这部分很简单,但是日期呢 $oDate = new DateTime($date); array( 'post_date' => $oDate->format('Y-m-d H:i:s'), 'post_date_gmt' => gmdate('Y-m-d H:i:s', $date), ); 试试这个: $oDate->setTimezone(new DateTimeZone('GMT')); $oDate->form
$oDate = new DateTime($date);
array(
'post_date' => $oDate->format('Y-m-d H:i:s'),
'post_date_gmt' => gmdate('Y-m-d H:i:s', $date),
);
试试这个:
$oDate->setTimezone(new DateTimeZone('GMT'));
$oDate->format('Y-m-d H:i:s');
试试这个:
$oDate->setTimezone(new DateTimeZone('GMT'));
$oDate->format('Y-m-d H:i:s');
在这种情况下,您需要两个对象,一个用于
GMT
$oDate = new DateTime($date);
$gmDate = new DateTime($date, new DateTimeZone('GMT'));
array(
'post_date' => $oDate->format('Y-m-d H:i:s'),
'post_date_gmt' => $gmDate->format('Y-m-d H:i:s'),
);
在这种情况下,您需要两个对象,一个用于
GMT
$oDate = new DateTime($date);
$gmDate = new DateTime($date, new DateTimeZone('GMT'));
array(
'post_date' => $oDate->format('Y-m-d H:i:s'),
'post_date_gmt' => $gmDate->format('Y-m-d H:i:s'),
);
只需将
DateTimeZone
实例作为第二个参数传递给DateTime
<代码>$date=新日期时间($date,新日期时区('GMT'))要获得完整的解释,请看:@ofirbarch太好了,我将关闭/删除此问题。我必须投票才能关闭我自己的问题。您只需将DateTimeZone
实例作为第二个参数传递到DateTime
<代码>$date=新日期时间($date,新日期时区('GMT'))代码>要获得完整的解释,请看:@ofirbarch太好了,我将关闭/删除此问题。我必须投票结束我自己的问题。不要忘记,这样做后,他希望回到标准时区。不要忘记,这样做后,他希望回到标准时区。