PHP-依靠系统的时区设置并不安全 [英] PHP - It is not safe to rely on the system's timezone settings
问题描述
我刚刚在Mac上激活/安装了PHP和mySQL,在访问使用日期的表之前,一切似乎都很顺利.
I have just activated/installed PHP and mySQL on my Mac and all seemed to be going well until I accessed a table which used dates.
在实时服务器上(我以前在该站点上开发过该服务器),同一页面工作正常.
On the live server - where I was previously developing the site - exactly the same page worked fine.
在我的本地站点上,表中的每一行都会收到以下消息:
On my local site I get the following messages for each row in the table:
Warning: strtotime() [function.strtotime]: 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 'Europe/London' for 'BST/1.0/DST' instead in /Users/mysite/Sites/testsite/index.php on line 26
Warning: date() [function.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 'Europe/London' for 'BST/1.0/DST' instead in /Users/mysite/Sites/testsite/index.php on line 26
任何想法如何阻止这种情况.我猜我需要在某个地方更改设置.
Any ideas how to stop this. I'm guessing I need to change a setting somewhere.
推荐答案
任何想法如何阻止这种情况.
Any ideas how to stop this.
错误消息告诉您如何停止此操作.
The error message tells you how to stop this.
要求使用date.timezone设置或date_default_timezone_set()函数.
You are required to use the date.timezone setting or the date_default_timezone_set() function.
将PHP安装的php.ini
(可能是/etc/php.ini
)文件更新为具有date.timezone
设置,或在脚本中使用date_default_timezone_set()
.
Update your PHP installation's php.ini
(likely /etc/php.ini
) file to have a date.timezone
setting, or use date_default_timezone_set()
in your scripts.
您现在才看到它,因为它开始在PHP 5.3+中发生.
You're only now seeing this because it starts happening in PHP 5.3+.
这篇关于PHP-依靠系统的时区设置并不安全的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!