PHP警告:date():依靠系统的时区设置并不安全. -OS X [英] PHP Warning: date(): It is not safe to rely on the system's timezone settings. - OS X

查看:575
本文介绍了PHP警告:date():依靠系统的时区设置并不安全. -OS X的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次在终端中运行命令时,都会收到此警告.它从我所有自制配方的最新更新和作曲家的更新开始.我已经查看了它所引用的文件,但不确定在这里做什么.

I've been getting this warning every time I run a command in the terminal. It started with a recent update of all of my homebrew formulas and updating composer. I've had a look into the file it's referencing but not sure what to do here.

完整消息

PHP警告:date():依靠系统的时区设置并不安全. 要求使用date.timezone设置或date_default_timezone_set()函数.如果您使用了这些方法中的任何一种,并且仍然收到此警告,则很可能您拼写了时区标识符.我们现在选择了时区"UTC",但是请设置date.timezone以选择您的时区.在第158行的/Users/ste/.composer/vendor/hoa/core/Parameter.php中

PHP Warning: date(): 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 /Users/ste/.composer/vendor/hoa/core/Parameter.php on line 158

在Parameter.php的158行上,我们有一个函数

On line 158 of Parameter.php we have a function

/**
 * Initialize constants.
 *
 * @return  void
 */
public static function initializeConstants()
{
    $c                = explode('…', date('d…j…N…w…z…W…m…n…Y…y…g…G…h…H…i…s…u…O…T…U'));
    self::$_constants = [
        'd' => $c[0],
        'j' => $c[1],
        'N' => $c[2],
        'w' => $c[3],
        'z' => $c[4],
        'W' => $c[5],
        'm' => $c[6],
        'n' => $c[7],
        'Y' => $c[8],
        'y' => $c[9],
        'g' => $c[10],
        'G' => $c[11],
        'h' => $c[12],
        'H' => $c[13],
        'i' => $c[14],
        's' => $c[15],
        'u' => $c[16],
        'O' => $c[17],
        'T' => $c[18],
        'U' => $c[19]
    ];

    return;
}'

我根本不在OS X上使用PHP.我的工作是通过VM或MAMP进行的,所以我不确定是否应该使用Composer的核心吗?

I don't use PHP on OS X at all. My work is via VMs or MAMP the odd time so I'm not sure if one should be playing around with the core of Composer?

推荐答案

您需要使用php.ini或php函数date_default_timezone_set()来设置时区.

You need to set the time zone, either using php.ini or with the php function date_default_timezone_set().

通过php.ini:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Europe/London 

或使用php:

date_default_timezone_set("Europe/London");

这篇关于PHP警告:date():依靠系统的时区设置并不安全. -OS X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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