是啊......真的有点慢,但评论和回答都是正确的。
日期时间:: getTimeZone获取()返回一个DateTimeZone对象,见doc
public DateTimeZone DateTime::getTimezone (void)
但你不一定需要的对象,但如果你想进入该领域,使用
$datetime->timezone
还是一个完整的例子:
$array = array(
'blah' => 0,
'date' => new Datetime(),
'blub' => 1
);
var_dump($array);
var_dump($array['date']->timezone);
var_dump($array['date']->getTimezone()->getName());
对外输出:
array(3) {
["blah"]=>
int(0)
["date"]=>
object(DateTime)#1 (3) {
["date"]=>
string(19) "2013-08-29 13:25:08"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/Berlin"
}
["blub"]=>
int(1)
}
string(13) "Europe/Berlin"
string(13) "Europe/Berlin"
你试过'$ formData ['date'] - > timezone;'? – Bora
你有什么错误? 'getTimezone'是一种方法,但它返回一个对象,而不是一个字符串[RTFM](http://www.php.net/manual/en/class.datetime.php),它返回一个DateTimeZone实例,所以你可能正在寻找' - > getTimezone() - > getName();' –