TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Handling different timezone (http://www.talkphp.com/advanced-php-programming/5130-handling-different-timezone.html)

captainmerton 11-24-2009 09:27 AM

Handling different timezone
 
On the shared hosting package I have the timezone is set to Central European Time for the php installation on the web server and the mysql database. I dont have root access to change this however i can alter settings using a php.ini file etc. I want to set both to London time. I was thinking of using this sql statement on every connection to the database:

SET time_zone = '-1:00';

I was also going to set the php time using this statement or alternatively just change it in the php.ini file:

ini_set('date.timezone', 'Europe/London');

The query I have is I've read somewhere that I will encounter problems when daylight saving changes etc come into play and the difference between CET and GMT isnt 1hr. I read somewhere that even setting the db timezone like this wont resolve this:

SET time_zone = 'Europe/London';

Anybody got any suggestions or guidance? Thanks.

ChrisR 12-10-2009 02:50 AM

This is how my friend done it.

make a function and make sure your server timezone is GMT

PHP Code:

function getTime($timzone){
return 
time() + 60 $timezone;
}

getTime(2); // Get's the current time of GMT+2 



All times are GMT. The time now is 09:40 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0