date(): It is not safe to rely on the system’s timezone settings
程序员文章站
2022-04-21 20:30:49
...
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.
PHP 5.3 + 需要在 php.ini 文件中配置 timezone, 或在调用 date() 函数之前使用 date_default_timezone_set() 方法设置 timezone
Case A:在 php.ini 文件中配置 timezone
#grep -B 1 timezone ./php.ini[Date]; Definesthedefault timezoneusedbythedatefunctions; http://php.net/date.timezonedate.timezone = "Asia/Shanghai"
之后重启你的 web/php 服务
Case B:
在调用 date() 函数之前 通过 date_default_timezone_set() 设置 timezone
eg:
/* set data timezone */date_default_timezone_set("PRC");$years = date('Y');
推荐阅读
-
解决php的“It is not safe to rely on the system’s timezone settings”问题
-
解决php的“It is not safe to rely on the system’s timezone settings”问题
-
PHP date()函数警告: It is not safe to rely on the system解决方法
-
PHP Warning: date(): It is not safe to rely on the system_PHP教程
-
PHP date()函数警告: It is not safe to rely on the system解决方法
-
解决php的“It is not safe to rely on the system’s timezone setti_PHP
-
解决php的“It is not safe to rely on the system’s timezone setti
-
解决php的“It is not safe to rely on the system’s timezone settings”问题,relytimezone
-
PHP Warning: date(): It is not safe to rely on the system_PHP教程
-
php Warning: phpinfo(): It is not safe to rely on the systems timezone settings.解决方法