Symfony2 Date.TimeZone()问题 [英] Symfony2 Date.TimeZone() Issue

查看:648
本文介绍了Symfony2 Date.TimeZone()问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过太阳下的所有功能,以便能够在安装Symfony2之后运行此命令。


php应用程序/控制台缓存:清除--no-warmup或php应用程序/控制台缓存:清除


我每次都收到这个错误:


[ErrorException]警告:date_default_timezone_get ():依靠系统的时区设置是不安全的。您需要 使用date.timezone设置或date_default_timezone_set()函数。如果您使用任何这些方法,并且您仍然收到此警告,您很可能拼写时区标识符。我们现在选择了时区'UTC',但请设置date.timezone来选择您的时区。 in / Applications / XAMPP / xamppfiles / htdocs / rt / vendor / jms / serializer-bundle / JMS / SerializerBundle / DependencyInjection Configuration.php第66行


第66行:


- > scalarNode('default_timezone') - > defaultValue( date_default_timezone_get )) - > end()


我已经尝试过这个Stack Post:


警告:date_default_timezone_get():


我已经尝试编辑所有php.ini文件,phpinfo()为XAMPP显示:


启用日期/时间支持
Olson时区数据库版本2013.4
时区数据库内部
默认时区UTC


$ php --ini显示


Co nfiguration File(php.ini)路径:/ etc(我也编辑了这个)


php.ini显示


date.timezone = UTC


我无法运行php composer.phar安装没有能力通过这个愚蠢的date_default_timezone_set()错误。请帮忙,这是两天的时间,试图让这个固定,我在我的智慧结束。



谢谢!

解决方案

代码到 app / AppKernel.php 文件:

 使用Symfony \\Component\HttpKernel\Kernel; 
使用Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel扩展内核{

public function init(){
//更改时区
date_default_timezone_set('America / Caracas');

parent :: init();
}

// ......
}


I have tried everything under the sun to enable the ability to run this command after installing Symfony2.

php app/console cache:clear --no-warmup OR php app/console cache:clear

I get this error every time:

[ErrorException] 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 /Applications/XAMPP/xamppfiles/htdocs/rt/vendor/jms/serializer-bundle/JMS/SerializerBundle/DependencyInjection Configuration.php line 66

On line 66:

->scalarNode('default_timezone')->defaultValue(date_default_timezone_get())->end()

I've tried this Stack Post:

Warning: date_default_timezone_get():

I've tried to edit ALL php.ini files, phpinfo() for XAMPP shows:

date/time support enabled "Olson" Timezone Database Version 2013.4 Timezone Database internal Default timezone UTC

$ php --ini shows

Configuration File (php.ini) Path: /etc (I edited this one as well)

php.ini shows

date.timezone = UTC

I cannot run php composer.phar install without the ability to get past this stupid date_default_timezone_set() error.

Please help, its been 2 haggling days trying to get this fixed and I am at my wits end.

Thanks!

解决方案

I've solved this issue adding this code to the app/AppKernel.php file:

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel {

    public function init() {
        // Change timezone
        date_default_timezone_set('America/Caracas');

        parent::init();
    }

    // ......
}

这篇关于Symfony2 Date.TimeZone()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆