...

View Full Version : Timezones



Taylor_1978
07-11-2005, 12:39 PM
Hiya,

Okay I am having a little difficulty with timezones.

First.. I have put this in my config.inc page:



// DATE/TIME SETTINGS:
$display[settime] = time() + $linfo[timezone]; // $linfo[timezone] is from the stored data in database, which is equivallent to the numeric value. eg. If the user has chosen +10 hours Sydney Australia as their zimezone, this value is: 54000. This is equal to 15 hours, due to the server being on American EST time.
$display[date] = date("F j, Y",$display[settime]);
$display[time] = date("h:i A",$display[settime]);


Now, I also have a function, which does exactly the same thing, but changes any value from the database to be viewed.

eg.



function showtime($convert) {
global $display;

$show[date] = date("F j, Y",$convert);
$show[time] = date("h:i A",$convert);

return $show;
}

$showtime = showtime($game[numeric]);


Does that make sense so far? lol

This way.. all times saved in the database, are inserted as the server time.

My problem is daylight savings. I'm unsure if this is going to cause a problem when it occours. eg. American daylight is different to Australian daylight. I know the date number accounts for daylight.. but I'm not sure if this will cause me problems or not, and don't really want to wait for it to happen to find out..

Am I making any sense? Cause I think I just confused myself lol.

Any suggestions o ideas of how to better combat this would be greatly appreciated.

Thanks in advance :thumbsup:

Taylor.

devinemke
07-11-2005, 06:39 PM
a common way of dealing with this problem is to store all of the date/times in the database as GMT, then to store individual user's timezones as integers (-43200 through 43200) being the offset from GMT (plus or minus). then it's simple matter of adding/subtracting the timezone integer from the GMT timestamp for display purposes.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum