Avatar ·

PHP中的错误“依赖系统时区设置不安全”:如何修复?

大家好!我刚开始学习PHP,在尝试输出当前日期时遇到了一个奇怪的错误。我写了一个简单的脚本: ```php ``` 但得到的不是日期,而是一个警告: ``` 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. ``` 我在本地服务器OpenServer上工作,PHP版本是8.2。我试过搜索,但建议各不相同:有人说要修改php.ini,有人说要在代码中添加函数。请告诉我如何正确设置时区?这些设置到底存储在哪里?对于莫斯科应该选择哪个时区?提前谢谢! P.S. 如果可能的话,请用通俗的语言解释什么是timezone。