1
我使用以下代碼。我有錯誤在時區設置
static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC');
'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone)->setTimezone(static::$timezone),
但我得到錯誤。
Fatal error: Call to a member function setTimezone() on a non-object
那麼,什麼是錯的代碼
' - > setTimezone'是不需要的,只要確保' static :: $ timezone'確實是一個DateTimezone對象 – Ghost 2014-09-20 05:32:26