安装脚本后出现时区错误

时间:2015-12-13 13:59:08

标签: php database timezone server cpanel

我收到错误消息----------

Warning: 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/user/public_html/cdemo/_include/lib/lib.php on line 73

Warning: 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/user/public_html/cdemo/_include/lib/lib.php on line 74



Error: E_WARNING
URL: http://mywebsite.com/demo/
File: /home/user/public_html/cdemo/_include/lib/db_common.php
Line: 69
Message: 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 the timezone 'UTC' for now, but please set date.timezone to select your timezone.

Call stack:

File: /home/user/public_html/cdemo/_include/lib/db_common.php (Line: 69)
Function: date

File: /home/user/public_html/cdemo/_include/core/start.php (Line: 199)
Class: DB_Common
Function: connect

File: /home/user/public_html/cdemo/_include/core/main_start.php (Line: 12)
Function: include

File: /home/user/public_html/cdemo/index.php (Line: 15)
Function: include

enter image description here

如何解决这个问题??

1 个答案:

答案 0 :(得分:0)

有两种方法可以解决这个问题:

  1. 在脚本的顶部(或mvc框架的条目文件)中使用内置函数date_default_timezone_set(timezone_of_your_place)。您可以在timezone_list中找到常量代表您所在位置的时区。

  2. php.ini更改配置项date.timezone = your_timezone

  3. 这两者的不同之处在于,方式1将立即生效,但仅限于该脚本的生命周期,并且方式2将在重新加载php配置文件后影响所有php脚本行为。