SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mapping zip codes to time zone - preferably with info about daylight savings

    This isn't specifically a PHP question but since that's what our app is using, I thought I'd start here. The application we're developing requires time stamps on certain things and they need to be based on the user's actual time. Obviously we can collect time zone info when they register but are there some behind the scenes way to get the information from the zip code they give us? Preferably something free.

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,179
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    Were it me, i'd use a database (GeoNames puts out a TSV file for the US: http://www.geonames.org/export/zip/US.zip ) to translate Zip to State, and then map State to time zone (geoip_time_zone_by_country_and_region)
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the tips.

  5. #5
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you possibly determine their time zone at the time of registration or some other time when the user is on the site via javascript? With this technique, you could look at their local time on their machine and use that to determine their time zone and post that data back to your server.

    This project allows you to determine the time zone via javascript:
    https://bitbucket.org/pellepim/jstimezonedetect

  6. #6
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kgh View Post
    Could you possibly determine their time zone at the time of registration or some other time when the user is on the site via javascript? With this technique, you could look at their local time on their machine and use that to determine their time zone and post that data back to your server.

    This project allows you to determine the time zone via javascript:
    https://bitbucket.org/pellepim/jstimezonedetect
    Wouldn't this have to assume that the user has their clock set correctly?

  7. #7
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    and that the user was allowing Javascript...
    and that the user never went on a business trip or vacation....
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  8. #8
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    and that the user was allowing Javascript...
    and that the user never went on a business trip or vacation....
    The Javascript isn't an issue because it's a fairly complex online app that they have to have a subscription to. One of the requirements for the app to work is that they allow Javascript. However, your observation about business trips or vacations is a good one because theoretically, a user MIGHT take their laptop on a business trip and want to get caught up on their record-keeping.

  9. #9
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,179
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    This is why you use geoIp to get their starting location (if you want) but allow them to enter their own zip if they see that it is incorrect, you can still use geoIp to obtain info based on that rather than IP


Bookmarks

Posting Permissions

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