Time in International Zone - how to handle this

Discussion in 'PHP' started by roxy, Apr 4, 2006.

  1. #1
    How do i mange Time.

    - Servers in US (So Server in US Time)
    - Target Audience in UK & Asia (Both different Time Zone)
    - I want to show local time when some body enters the site

    - How do i do it.
    - Any addional db needs to be integrated.
    - how this stuff can be coded.

    Roxy.
     
    roxy, Apr 4, 2006 IP
  2. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    2 ways:
    1) Use javascript to take the time straight off the users PC
    2) Use a geolocation script to find the country from the IP and then adjust the time accordingly.
     
    mad4, Apr 5, 2006 IP
  3. roxy

    roxy Active Member

    Messages:
    319
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #3
    I can take country from profile section of the site , so IP may not be required in my case but following queries

    1) Do any body know DB for Country + GMT Time Database

    2) Do you know a smilar java script that does for atleast 15 to 20 countries on on load
     
    roxy, Apr 5, 2006 IP
  4. mad4

    mad4 Peon

    Messages:
    6,986
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #4
    mad4, Apr 5, 2006 IP
  5. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    do you actually store any time data in your database or do you just want to display a local time to the user?
    The method I use is:
    - store the time data on server in GMT
    - use javascript to get the timezoneoffset in hours (from GMT), ie +1, +8, -4 etc from user
    - display time = time from database + $offset in secs
     
    rosytoes, Apr 5, 2006 IP
  6. roxy

    roxy Active Member

    Messages:
    319
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #6
    I am storing in database i am sure it can not be done by simply pure js , any body have idea of GMT DB
     
    roxy, Apr 5, 2006 IP
  7. rosytoes

    rosytoes Peon

    Messages:
    230
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You don't need to do it all in JS. All you need JS to do is to get the offset from GMT. Once you get that, you offset the time stored in your db by the amount you get from your JS code. You don't need any extra db either.
     
    rosytoes, Apr 7, 2006 IP