刚刚意识到为什么我的网站现在显示所有日期时间变量为-1小时......我第一次使用Codeigniter! (以前从未出现过这种问题)Codeigniter时区mysql设置
所以,我已经包含在我的主index.php文件下面的代码
/*
|---------------------------------------------------------------
| DEFAULT TIMEZONE
|---------------------------------------------------------------
|
| Set the default timezone for date/time functions to use if
| none is set on the server.
|
*/
if(! ini_get('date.timezone'))
{
date_default_timezone_set('GMT');
}
但是,它仍然显示为-1小时,所以我假设我需要设置某种对MySQL默认设置的...
我已经包括下面的代码行中我的模型:
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->db->query("SET time_zone='+0:00'");
}
仍然没有区别...帮助!
我的代码是:
<h3><?=date('D, jS F @ g:ia', strtotime($row->datetime))?></h3>
的$按行>日期时间变量无非是从我的MySQL数据库中的DATETIME列值更。鉴于回送的变量总是比我的数据库中值少1小时...
我的模型代码是:
function coming_up()
{
$this->db->query("SET time_zone='+0:00'");
$query = $this->db->query('SELECT * FROM events1 WHERE datetime >= NOW() ORDER BY datetime LIMIT 2');
return $query->result();
}
没有改变我怕...... @Rohan库马尔 – user2505513
检查'插入query'它应该看起来像'$ this-> db-> query(“INSERT INTO TABLE SET time_zone ='+ 0:00'”);' –
请参阅上文,我编辑了我的帖子以包含我的查询代码@Rohan Kumar仍然没有区别! – user2505513