代码点火器电子邮件配置文件导致日期()时区错误


Codeigniter email config file causes date() timezone error

Codeigniter 3.0.3我刚刚在application''config文件夹中创建了新的email.php配置文件

我试图在配置数组中只添加一个参数,然后如果我打开我的web应用程序,我会收到下面的消息,

以下是配置参数,

$config = array(
'mailtype'  => 'html'
);

遇到PHP错误

Severity: Warning
Message: 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.
Filename: libraries/Email.php
Line Number: 1036

如果我从数组中删除内容,则没有消息,我不确定是什么原因导致这个错误添加配置数组,

有什么想法吗?

谢谢,

您可能需要将时区放在php.ini文件的配置行中。您应该在php.ini文件中有这样一个块:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = America/New_York

如果没有,请添加它(用您的时区替换时区)。配置后,请确保重新启动httpd(服务httpd重新启动)。

在这里,您可以找到所有支持的时区列表。

这是因为php配置中没有设置时区。

将以下代码行添加到php.ini文件的顶部

date.timezone = "US/Central"

并重新启动web服务器

您也可以使用以下函数通过php脚本进行设置:

date_default_timezone_set('America/Los_Angeles');

您可以在index.php 中添加

if( ! ini_get('date.timezone') ){
   date_default_timezone_set('GMT');
}

问题是您还没有设置时区

您需要设置服务器的时区。接下来的步骤对我有效。

您必须打开system/libraries/Email.php并找到函数_set_date()。把下面的代码行放在函数的顶部。

date_default_timezone_set('UTC'); // <-- 'UTC' is a string to define timezone

然后,功能应具有以下结构

protected function _set_date()
{
    date_default_timezone_set('UTC');
    $timezone = date('Z');
    ...
}