php - Symfony2 Date.TimeZone() 问题

标签 php mysql date symfony datetime

为了在安装 Symfony2 后能够运行此命令,我已尝试了一切方法。

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

我每次都会收到此错误:

[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

第 66 行:

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

我已经尝试过这个堆栈帖子:

Warning: date_default_timezone_get():

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

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

$ php --ini 显示

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

php.ini 显示

date.timezone = UTC

如果无法克服这个愚蠢的 date_default_timezone_set() 错误,我就无法运行 php Composer.phar install 。

请帮忙,为了解决这个问题已经讨价还价了两天,我已经无计可施了。

谢谢!

最佳答案

我已经解决了这个问题,将此代码添加到 app/AppKernel.php 文件中:

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();
    }

    // ......
}

关于php - Symfony2 Date.TimeZone() 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23352322/

相关文章:

mysql - SQL 查询 nvarchar 至今

java - 如何在 Java 中的日期对象中存储和检索毫秒数?

php - 如何在 PHP 中显示取决于用户输入的长查询的 MySQL 错误?

php - 创建一个自动创建新数据库条目的函数

php - INSERT INTO 无法正常工作 MySQL

php - MySQL 查询中的 SORT BY 不会改变查询结果数组中的顺序

Mysql - 将多个 INT 字段连接在一起以创建 DATE 字段

php - 用 PHP 解析 XML?

php - SQL语句获取DISTINCT结果,ORDER BY Random

php - 删除一行数据库 PHP SQL