Codeception日期时间错误

TH1*_*981 2 php yii codeception

我正在尝试学习Codeception并将它与Yii(我也是新手)一起使用.

开箱即用,我在运行测试时遇到了一些问题.我已经浏览了快速入门指南,当我通过终端运行时,我收到此错误:

Codeception PHP Testing Framework v1.6.6
Powered by PHPUnit 3.7.24 by Sebastian Bergmann.

  [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 tim  
  ezone identifier. We selected 'America/Chicago' for 'CDT/-5.0/DST' instead                                                                          
Run Code Online (Sandbox Code Playgroud)

现在,我正在使用MAMP,并在我的php.ini文件中设置了时区.我也试过在index.php文件中手动设置它_default_timezone_set('America/Chicago');,我仍然得到相同的消息.

当我使用Yii时,我已经尝试为Codeception启用Yii模块,但这似乎没有任何区别.

更新

我已经尝试在非基于yii的项目上安装代码,所以一个直接的网站,我得到与上面完全相同的错误.

eva*_*mcd 6

我有同样的问题,发现date.timezone在php.ini 中设置设置解决了这个问题.

  1. 打开php.ini(在Mac上是/private/etc/php.ini)
  2. 搜索'timezone'.第一次点击应该是这个设置
  3. 取消注释该行;date.timezone =(删除;)
  4. 将您的时区添加为字符串,例如"America/New_York",整行读取date.timezone = "America/New_York"
  5. 保存文件并重新启动Web服务器

时区选项列表如下:http: //www.php.net/manual/en/timezones.php

希望有所帮助.