剛剛意識到爲什麼我的網站現在顯示所有日期時間變量爲-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