Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Timezones

  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts

    Exclamation Timezones

    Hiya,

    Okay I am having a little difficulty with timezones.

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

    PHP Code:
    // 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.

    PHP Code:
    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

    Taylor.

  • #2
    Regular Coder devinemke's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    443
    Thanks
    0
    Thanked 12 Times in 11 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •