0

I have read loads of posts and howto's and virtually every one I have found says "can't be done" or "can't be done reliably" or "not cross browser compatible". All the articles I have read basically fall back to the suggestion of "make a user setting".

However when I login to cpanel, it automatically detects my timezone. When I visit most calendar software apps they automatically convert to my timezone. When I use my webinar software, the webinar times are automatically converted for the user when they visit the page - no login required - seems to work in IE, FF, Chrome, Opera, Edge, and a few offshoot browsers.

So without suggesting it can't be done, its not reliable, I have to use offsets (my cookies show they are actually setting America/Denver NOT an offset), that its not cross browser compatible, etc.... can someone tell me HOW they are doing this?

Bruce
  • 1,039
  • 1
  • 9
  • 31
  • http://stackoverflow.com/questions/13/determine-a-users-timezone –  Aug 27 '16 at 21:33
  • 1
    Because the place is calculated afterwards. There is no way of knowing your geographical position unless you use the IP, or you try to estimate it with the time offset. Calm down, tone down. –  Aug 27 '16 at 21:42
  • That post does not at all explain how they are setting the cookie without using offset, and if they are using offset it doesn't explain how they are taking DST into account. As said in my question, they are literally storing "America/Denver" Not a number of hours, minutes, days, nor times to offset by. – Bruce Aug 27 '16 at 21:42
  • Okay so this givens me something to research. So it would seem (based on your reply) that they are using either IP or referring location information to determine the timezone. The question then becomes how are they determining the timezone based on location. Are we suggesting they likely wrote a function to test every major location to its timezone? There has to be a better way. – Bruce Aug 27 '16 at 21:45
  • http://stackoverflow.com/questions/19331627/good-geolocation-api-by-ip –  Aug 27 '16 at 21:46
  • now thats what I am talking aboutt! This solution needs shared more! :) – Bruce Aug 27 '16 at 21:51

1 Answers1

1

What you are requesting is not possible based on the time zone, since more than one location has the same time zone.

As pointed out in this answer, you can use this database to find out the user geolocation based on its ip.

The API returns the location of an IP address (country, region, city, zipcode, latitude, longitude) and the associated timezone in XML format. You can find below code samples with PHP, Javascript, Ruby, Python and ASP.

In the API website it's well explained how you can make the requests. If you use jQuery, use AJAX. If you rather go for it in the server side, then check how to do it depending on the language you are using.

You can get the user IP in the headers request if you are on the server side, and there are other methods on the client side.

Community
  • 1
  • 1