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');
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号