Welcome Guest, Not a member yet? Register   Sign In
Timezone settings are wrong!
#1

[eluser]Unknown[/eluser]
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

Code:
/*
    |---------------------------------------------------------------
    | 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:

Code:
function __construct()
        {
            // Call the Model constructor
            parent::__construct();
            $this->db->query("SET time_zone='+0:00'");
        }

Still no difference... Help!

My view code is:

Code:
<h3>&lt;?=date('D, jS F @ g:ia', strtotime($row->datetime))?&gt;</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:

Code:
function coming_up()
    {
    $query = $this->db->query('SELECT * FROM events WHERE datetime >= NOW() ORDER BY datetime LIMIT 2');
    return $query->result();
    }

HELP!
#2

[eluser]Syllean[/eluser]
I'm not sure where you're located but I would guess that you are forgetting about daylight savings time. Europe/London time is not GMT time during Daylight Savings, it's GMT+1.




Theme © iAndrew 2016 - Forum software by © MyBB