how to prepare various timezone reports

Discussion in 'PHP' started by adrevol, Jul 11, 2008.

  1. #1
    Hi,


    My database server time zone is GMT-4.00 and i want to generate a report in various time zones like GMT,GMT+5.30, GMT+9.30 ...

    How i am doing is
    lets assume i am taking report for 9 july 2008 in GMT+9.30 timezone ..
    now, 9 july 2008 +4 hrs + 9.30 hrs will become my actual resultant time limit ..

    in that case .. i will get both 9 th and 10th report .. but i want that as only 9th ..

    will set time_zone="+9:30" and then querying will solve my problem or ... how to do that ...

    Problem in simple scenario is ... lets take Google Analytics .. lets assume that the database server time zone is GMT-4:00 .. when you register with analytics and pick up the timezone as GMT +5:30 .. Now all your reports will come as GMT+5:30 .. How they are doing it .....

    Thanks in advance
    Adrevol
     
    adrevol, Jul 11, 2008 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Danltn, Jul 11, 2008 IP
  3. adrevol

    adrevol Active Member

    Messages:
    124
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #3
    the answer in the above does not solve my problem ...

    because ... with the above adjusting timezone .. you can query database with converted times .. but .. what i want is resultset from database should be converted to the desired timezones ...
     
    adrevol, Jul 11, 2008 IP
  4. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #4
    I'm guessing you are storing your dates as UNIX times, couldn't you just change the date('U') part to the result set UNIX time?

    Should work fairly easily.

    You could always just use date_default_timezone_set.

    Examples:
    date_default_timezone_set('Etc/GMT-5'); (This is GMT + 5)
    date_default_timezone_set('Etc/GMT+8'); (This is GMT - 8, West coast US)
    PHP:
    Dan
     
    Danltn, Jul 11, 2008 IP