我有一个 Symfony2 项目。我今天将 php 更新到 5.5.7,从那时起,我得到了
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...
我在 php.ini 中设置了默认时区
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Europe/Paris";
为了确保这是好的 php.ini,我正在检查
phpinfo();
我到达那里的路径是我正在修改的路径:
/usr/local/php5.5.7/lib
但在那里,我看到
Default timezone UTC
这很奇怪。
任何想法?谢谢。
也许你正在尝试在 Apache 中设置它php.ini
,但是你的 CLI(命令行界面)php.ini
不好。
找你的php.ini
使用以下命令创建文件:
php -i | grep php.ini
然后搜索date.timezone
并将其设置为"Europe/Amsterdam"
。所有有效时区都可以在这里找到http://php.net/manual/en/timezones.php
另一种方式(如果另一种不起作用),搜索文件AppKernel.php
,它应该在文件夹下app
你的Symfony项目目录。覆盖__construct
类下面的函数AppKernel
:
<?php
class AppKernel extends Kernel
{
// Other methods and variables
// Append this init function below
public function __construct($environment, $debug)
{
date_default_timezone_set( 'Europe/Paris' );
parent::__construct($environment, $debug);
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)