Welcome Guest, Not a member yet? Register   Sign In
Wrong server timezone?
#1

[eluser]Unknown[/eluser]
I'm facing a strange problem with time in my application.
The server on which my project is hosted is in the UK (UTC) and I live in Italy (UTC + 1:00).
I'll explain my problem through examples.

time() on localhost = 12:00
time() on the UK server = 11:00

And that's OK. But if I use now() setting $config['time_reference'] = 'gmt' here's what I get:

now() on localhost = 10:00 (that's OK, -1 for the timezone and -1 for the daylight saving)
now() on the UK server = 09:00

Isn'that strange? I mean, GMT should be the same all around the world (in this case 10:00)...
UK has no timezone shift, GMT should be just -1 because of the daylight saving, shouldn't it?
And it's not a problem of CI's now() function, I get the same results with PHP's gmdate().
To get the correct time with gmt_to_local() I have to set $timezone to 'UP2', which isn't correct.

Is there something wrong with the UK server settings? can anyone with a project on a server in a different timezone than his own confirm this?
Or am I missing something about how all this time stuff work?

Thanks :-)
#2

[eluser]alexsancho[/eluser]
I've got a similar problem, and solved it setting default timezone to my country timezone and using $config['time_reference'] = "local"

Since my host is using PHP5 i can do this

Code:
if(function_exists('date_default_timezone_set')) {                                                                                                                    
            $tz= $this->obj->config->item('timezone');                                                
            date_default_timezone_set($tz);                                                                                                                                  
        }

I've added a config option where i can setup the timezone, "Europe/madrid" in my case

hope this help
#3

[eluser]Unknown[/eluser]
Thanks for your reply, unfortunately my host will keep PHP 4.3.2 at least until September :-(
I really can't believe it's so difficult to correctly set the time on a server, if I can do it on my PC...
So I suppose it would also work setting default timezone to UTC and using $config[’time_reference’] = “gmt”.
This would be useful if you want let each user set his timezone, of course.




Theme © iAndrew 2016 - Forum software by © MyBB