Php Symfony 2.7:未设置默认时区,导致致命错误

Php Symfony 2.7:未设置默认时区,导致致命错误,php,symfony,timezone,server,Php,Symfony,Timezone,Server,我正在尝试在共享服务器上设置基于symfony 2.7的应用程序,并且没有权限更改php.ini 正在执行:php应用程序/控制台原则:schema:drop--force 输出此警告/错误: PHP Warning: Uncaught exception 'Symfony\Component\Debug\Exception\ContextErrorException' with message 'Warning: date_default_timezone_get(): It is not

我正在尝试在共享服务器上设置基于symfony 2.7的应用程序,并且没有权限更改php.ini

正在执行:
php应用程序/控制台原则:schema:drop--force

输出此警告/错误:

PHP Warning:  Uncaught exception 'Symfony\Component\Debug\Exception\ContextErrorException' with message 'Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.'
0 [internal function]: Symfony\Component\Debug\ErrorHandler-    >handleError(2, 'date_default_ti...', '/path...', 272, Array)
1 /domain.com/app/vendor/monolog/monolog/src/Monolog/Logger.php(272): date_default_timezone_get()
2 /domain.com/app/vendor/monolog/monolog/src/Monolog/Logger.php(481): Monolog\Logger->addRecord(100, 'Notified event ...', Array)
3 /domain.com/app/vendor/symfony/ in /domain.com/app/vendor/monolog/monolog/src/Monolog/Logger.php on line 272
PHP Fatal error:  date_default_timezone_get(): Timezone database is corrupt - this should *never* happen! in /domain.com/app/vendor/monolog/monolog/src/Monolog/Logger.php on line 272
PHP Warning:  date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /domain.com/app/vendor/monolog/monolog/src/Monolog/Logger.php on line 272
PHP Fatal error:  date_default_timezone_get(): Timezone database is corrupt - this should *never* happen! in /domain.com
我试过:

输出下一个错误:

PHP Fatal error:  Uncaught exception 'Symfony\Component\Debug\Exception\ContextErrorException' with message 'Notice: date_default_timezone_set(): Timezone ID 'Europe/Berlin' is invalid' in /domain.com/app/app/AppKernel.php:42
根据
欧洲/柏林的规定
是一个有效的标识符

根据
timezonedb.所以应该安装
(不是)

根据需要,可以在
设置.yml
中设置
默认时区。对于
=2.0
,我找不到类似的配置。 编辑:“与Symfony 1.4不同,Symfony 2中没有设置默认时区的默认\u时区配置参数。[…]”()

有什么想法,如何解决这个问题


提前谢谢

建议您在php.ini中设置时区,但如果您在共享环境中或由于某种原因无法访问时区,则可以将其添加到
app/AppKernel.php

class AppKernel extends Kernel
{
        public function __construct($environment, $debug)
        {
            date_default_timezone_set( 'America/Detroit' );
            parent::__construct($environment, $debug);
        }
}

对于我来说,@wonde回答不起作用,我不知道为什么,这对我起作用了

ini_set('date.timezone', 'Europe/Berlin');
在文件中添加此行:

/web/app_dev.php

/web/app.php

如果这不起作用,也可以添加内核


那帮我解决了问题

出现错误消息是因为php.ini文件中未设置默认时区。请看一下这个答案@Praveesh如上所述,我已经尝试过这个解决方案,但不幸的是我仍然不能编辑php.ini。只需更改您的主机即可。@Paziツ 我试图避免它,但我想,这是唯一的解决办法。这是最好的解决办法。这样限制的主机不值得麻烦..或者将同一行添加到web/app.php
ini_set('date.timezone', 'Europe/Berlin');