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/no DST'
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
仍然得到警告.
有什么建议吗?
感谢您抽出宝贵的时间.
Thanks for taking the time.
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).