Just realised WHY my site is now showing all datetime variables as -1 hr... I'm using Codeigniter for the first time! (Never had this problem before)
So, I have included the following code in my main index.php file
/*
|---------------------------------------------------------------
| 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');
}
However, it's still showing as -1 hr, so I'm assuming I need to set some sort of default setting for MySQL...
I have included the following line of code in my model:
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->db->query("SET time_zone='+0:00'");
}
Still no difference... Help!
My code is:
<h3><?=date('D, jS F @ g:ia', strtotime($row->datetime))?></h3>
The $row->datetime variable is nothing more than a DATETIME column value from my MySQL database. The echoed variable in view is ALWAYS 1 hour less than the value in my database...
My model code is:
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();
}
$this->db->query("SET time_zone='America/Chicago'");
note you'll need to have the mysql time zones setup mysql_tzinfo_to_sql – Girth