`[Exception] DateTime :: __ construct():`依赖系统的时区设置是不安全的

kem*_*mal 17 php timezone exception codeception

我正在使用codeception(bdd)进行测试但却出错

[Exception]                                                                                                
  DateTime::__construct(): 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 
Run Code Online (Sandbox Code Playgroud)

任何这些
方法,你仍然得到这个警告,你很可能拼写错误的时区标识符.

我们选择Europe/HelsinkiEEST/3.0/DST;

我可不可以做?

Yah*_*yaE 16

您可以date_default_timezone_set('Europe/Istanbul');在运行此代码之前使用.

对于其他时区,请检查PHP时区


Tro*_*Tro 7

这是PHP配置的问题,而不是Codeception本身.

在命令行运行$ php -i | grep 'Configuration File',然后导航到该文件夹​​.编辑php.ini并找到说出date.timezone并将其设置为的行date.timezone = "Europe/Helsinki"