我有一个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中设置了默认时区.伊尼

[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 

这很奇怪.

有什么 idea 吗?谢谢.

推荐答案

也许您正试图在Apache的php.ini中设置它,但您的CLI(命令行界面)php.ini并不好.

使用以下命令查找php.ini文件:

php -i | grep php.ini

然后搜索date.timezone并将其设置为"Europe/Amsterdam".所有有效时区将在这里找到

另一种方法(如果另一种方法不起作用),搜索文件AppKernel.php,它应该位于Symfony项目目录的app文件夹下.覆盖AppKernel类中下面的__construct函数:

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

}

Php相关问答推荐

编写WooCommerce多步骤签出

WooCommerce在store 页面上显示兼容多语言的产品属性

将购买限制在WooCommerce中具有相同产品属性的项目

返回WooCommerce中的所有已启用变体

如何在汇总表构建器中操作LALAVEL细丝Sum::Make()值

模仿GUZLE中的curl 工作脚本(分块数据和二进制上传一起)

将自定义字段添加到管理产品 在 WooCommerce 3.2+ 中批量编辑

PHP 支持 APNG 文件吗?

如何在 Laravel 中app文件夹之外的文件夹内创建文件路径?

woocommerce checkout 页面上的自定义字段

产品页面自定义复选框可对 WooCommerce 购物车小计启用百分比折扣

使用产品自定义字段作为 WooCommerce 中特定用户角色的折扣百分比

通过ajax发送数据到下拉列表未完全设置为所选

在 php 中生成 MAC ISO/IEC 9797-1

在WooCommerce购物车和 checkout 页面中更改总计文本

如何使用 WhatsApp Cloud API 向 WhatsApp 发送消息,而无需在发送消息之前注册收件人号码?

在 GA4 Data API V1 Beta 中使用 inListFilter 过滤器时出错

PHP Loop 在迭代中使用修改后的数据

如何从 PHP 中的字符串位置排除图像扩展名

用于多态服务的 Symfony setter 注入