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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17682725/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:14:50  来源:igfitidea点击:

`[Exception] DateTime::__construct(): `It is not safe to rely on the system's timezone settings

phpexceptiontimezonecodeception

提问by kemal

I 'm using codeception (bdd) making test but gives error

我正在使用 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 

any of those
methods and you are still getting this warning, you most likely misspelled the timezone identifier.

这些
方法中的任何一种并且您仍然收到此警告,您很可能拼错了时区标识符。

We selected Europe/Helsinkifor EEST/3.0/DSTinstead ;

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

can i do?

我可不可以做?

回答by YahyaE

You can use date_default_timezone_set('Europe/Istanbul');before running this code.

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

For other timezones, check PHP Timezones

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

回答by Tro

This is an issue with your PHP configuration, not with Codeception itself.

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

In the command line run $ php -i | grep 'Configuration File', and then navigate to that folder. Edit php.ini and find the line that says date.timezoneand set it to date.timezone = "Europe/Helsinki"

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