沃梦达 / 编程问答 / php问题 / 正文

PHP 配置:依赖系统的时区设置是不安全的

PHP Configuration: It is not safe to rely on the system#39;s timezone settings(PHP 配置:依赖系统的时区设置是不安全的)

本文介绍了PHP 配置:依赖系统的时区设置是不安全的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个奇怪的.我刚刚升级到 php 5.3.0,升级后我收到以下警告:

Here a weird one. I just upgrade to php 5.3.0 and since the upgrade I'm getting the following warning:

警告:getdate() [function.getdate]:依赖系统的安全性是不安全的时区设置.你是必需的使用 date.timezone 设置或date_default_timezone_set()功能.如果您使用任何那些方法,你还在收到此警告,您很可能时区标识符拼写错误.我们选择美国/芝加哥"为'CST/-6.0/无夏令时'

Warning: getdate() [function.getdate]: 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 'America/Chicago' for 'CST/-6.0/no DST'

看了各种论坛,大家都说要解决这个问题,你只需要编辑php.ini中的日期区,然后重启Apache即可.

After looking in various forums, everybody says that to solve the problem, all you have to do is edit the date zone in the php.ini and restart Apache.

它对我不起作用.

我试过了

date.timezone="America/New_York"

date.timezone=America/New_York

date.timezone="US/Central"

更改后重新启动 apache.

Restarted apache after I made the change.

由于我仍然安装旧版本的 php,我什至确保我正在编辑当前版本的 php 在加载时使用的 php.ini

Since I still have the older version of php install, I even made sure that I'm editing the php.ini that the current version of php uses at the time to load

/usr/local/php5/lib/php.ini

仍然收到警告.

有什么建议吗?

感谢您抽出宝贵时间.

推荐答案

对原始问题发表评论的 Tchalvak 为我一针见血.我一直在编辑(我使用 Debian):

Tchalvak, who commented on the original question, hit the nail on the head for me. I've been editing (I use Debian):

/etc/php5/apache2/php.ini

...它对我来说具有正确的时区,并且是唯一一个在其中加载了 date.timezone 的 .ini 文件,但是当我通过 Bash 运行脚本时收到上述错误.我不知道我应该一直在

...which had the correct timezone for me and was the only .ini file being loaded with date.timezone within it, but I was receiving the above error when I ran a script through Bash. I had no idea that I should have been editing:

/etc/php5/cli/php.ini

也是.(好吧,对我来说它是同样",对你来说当然可能会有所不同,但我现在要让我的 Apache 和 CLI 版本的 php.ini 保持同步).

as well. (Well, for me it was 'as well', for you it might be different of course, but I'm going to keep my Apache and CLI versions of php.ini synchronised now).

这篇关于PHP 配置:依赖系统的时区设置是不安全的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:PHP 配置:依赖系统的时区设置是不安全的

基础教程推荐