[英]Symfonys date_default_timezone_get()
So I installed composer and apache and mysql, and then installed symfony, but after the installation it tells me to change the date because it is not reliable and then I can use it freely. 因此,我安装了composer以及apache和mysql,然后安装了symfony,但是安装后它告诉我更改日期,因为它不可靠,然后我可以自由使用它。
I have changed the date in php.ini with Europe/Bucharest but is still get this message: 我已经使用Europe / Bucharest更改了php.ini中的日期,但仍然收到此消息:
[Symfony\Component\Debug\Exception\ContextErrorException]
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 me
thods and you are still getting this warning, you most likely misspelled th
e timezone identifier. We selected the timezone 'UTC' for now, but please s
et date.timezone to select your timezone.
I use fedora 23 32-bit.I have looked over other solutions but none of them work. 我使用的是32位的fedora 23,我查看了其他解决方案,但没有一个起作用。
In Symfony2 just add this at the end of your class app/AppKernel.php : 在Symfony2中,只需将其添加到类app / AppKernel.php的末尾:
public function init() {
date_default_timezone_set( 'Europe/Bucharest' );
parent::init();
}
In Symfony3, use : 在Symfony3中,使用:
public function __construct($environment, $debug) {
date_default_timezone_set('Europe/Bucharest');
parent::__construct($environment, $debug);
}
public function __construct($environment, $debug)
{
parent::__construct($environment, $debug);
date_default_timezone_set('Asia/Shanghai');
}
I use this in symphony 2.3 我在交响乐2.3中使用此
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.