Sch*_*ger 1 php mysql datetime symfony
所以我安装了composer和apache以及mysql,然后安装了symfony,但安装后它告诉我更改日期因为它不可靠然后我可以自由使用它.
我已经在欧洲/布加勒斯特的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.
Run Code Online (Sandbox Code Playgroud)
我使用Fedora 23 32位.我已经查看了其他解决方案,但没有一个工作.
在Symfony2中,只需在类app/AppKernel.php的末尾添加:
public function init() {
date_default_timezone_set( 'Europe/Bucharest' );
parent::init();
}
Run Code Online (Sandbox Code Playgroud)
在Symfony3中,使用:
public function __construct($environment, $debug) {
date_default_timezone_set('Europe/Bucharest');
parent::__construct($environment, $debug);
}
Run Code Online (Sandbox Code Playgroud)