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

时间:2011-05-17 14:49:35

标签: php mysql timezone

我刚刚在我的Mac上激活/安装了PHP和mySQL,直到我访问了一个使用日期的表,所有这些似乎都很顺利。

在我刚开发网站的实时服务器上 - 完全相同的页面工作正常。

在我的本地网站上,我为表格中的每一行收到以下消息:

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

任何想法如何阻止这一点。我猜我需要在某处更改设置。

1 个答案:

答案 0 :(得分:12)

  

任何想法如何阻止这一点。

错误消息告诉您如何停止此操作。

  

必需使用date.timezone设置或date_default_timezone_set()函数。

更新您的PHP安装php.ini(可能是/etc/php.ini)文件以获得date.timezone设置,或在脚本中使用date_default_timezone_set()

你现在才看到这个,因为它开始在PHP 5.3 +中发生。

相关问题