Wrong server timezone? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Wrong server timezone? (/showthread.php?tid=1723) |
Wrong server timezone? - El Forum - 06-22-2007 [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 :-) Wrong server timezone? - El Forum - 06-22-2007 [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')) { I've added a config option where i can setup the timezone, "Europe/madrid" in my case hope this help Wrong server timezone? - El Forum - 06-22-2007 [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. |