You could do that, but it's important to understand that it's a heuristic and not a real concrete method.
Another heuristic might be to look at the language preference information you get from the browser. You can guess that "en-US" is probably one of four time zones.
Still another would be a wild guess based on the server's local time. You can guess that most of your hits at any time of day come from time zones that are in "waking hours" at that time (i.e., the Australians are active at a different time than the Americans).
Quite a few sites I've been to (including this one) ask me my time zone as part of my user preferences. This is evidence enough for me that there isn't a good and easy solution to this problem.
| [reply] |
it's important to understand that it's a heuristic and not a real concrete method.
I would never call it a heuristic since it makes use of a database lookup. The database can be huge. By contrast, a heuristic makes a guess based on (very) limited info.
If you use Geo::IP you can use the free though somewhat limited database, or, if you want a better precision — and likely, fewer errors, then you can pay for a bigger, commercial database from the same company who brought you the module.
n.b. I see that for the latter they require you need to be an "established business". That may be out of the reach of many developers here who may be wanting to use it for their own little projects.
Personally I think I'd go for the Lite version, and give the user the option to correct the guessed time zone, possibly making use of Javascript to automate it, for people who have Javascript enabled for your site.
| [reply] |
I think we agree on how geolocation by IP works and that it has faults, just not on whether to call that a "heuristic".
I'm not familiar with where those databases get their information, but unless they're somehow tracking users in real time, there's bound to be faults. When I VPN from New York to my closet in Chicago, there isn't any way for the database to know that. People travel and networks tunnel, and that's leaving aside users of things like Tor who've deliberately taken steps to hide who and where they are.
There are lots of ways to guess, some better than others, but not really any way to know.
| [reply] |