这是一个奇怪的。 我刚刚升级到 php 5.3.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即可。
它对我不起作用。
我试过了
date.timezone="America/New_York"
date.timezone=America/New_York
date.timezone="US/Central"
更改后重新启动 apache。
由于我仍然安装旧版本的 php,我什至确保我正在编辑当前版本的 php 加载时使用的 php.ini
/usr/local/php5/lib/php.ini
仍然收到警告。
有什么建议吗?
感谢您抽出宝贵时间。
最佳答案
对原始问题发表评论的 Tchalvak 为我一针见血。我一直在编辑(我使用 Debian):
/etc/php5/apache2/php.ini
...它对我来说具有正确的时区,并且是唯一一个在其中加载了 date.timezone 的 .ini 文件,但是当我通过 Bash 运行脚本时收到上述错误。我不知道我应该一直在编辑:
/etc/php5/cli/php.ini
也是。 (好吧,对我来说它是“同样”,对你来说当然可能会有所不同,但我现在要让我的 Apache 和 CLI 版本的 php.ini 保持同步)。
关于PHP 配置 : It is not safe to rely on the system's timezone settings,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2213608/