Forum: Ruby on Rails Setting time zone based on IP?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
328f0bb678423fcea01ebe3b0edc74e6?d=identicon&s=25 Ben Johnson (benjohnson)
on 2007-06-16 17:23
Is it possible to set a person's time zone based on their IP or some
other factor than specifying their time zone?
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2007-06-16 18:27
(Received via mailing list)
Hi Ben,

Ben Johnson wrote:

> Is it possible to set a person's time zone based on their IP

Not with any degree of certainty.  IP addresses are not 'handed out'
based
on geographic location.

> or some other factor than specifying their time zone?

The decision about the time zone a particular spot on the earth will use
is
a political one.  There are states in the US, for example, that do not
use
Daylight Savings Time.  So clocks within some states within the Central
Time
Zone will be set to CST while others will be set to CDT.  It gets worse.

If you really want to know what time zone a visitor is in, you need to
ask.

hth,
Bill
04952a6ee948f345e9c3727850d09a1b?d=identicon&s=25 dima (Guest)
on 2007-06-16 20:08
(Received via mailing list)
Bill is absolutely right.
You can guess the users location based on their IP but not precise
enough.
The only way that will be satisfactory is to ask the user for that
kind of information.

The alternative way will be to use a little javascript function that
will collect users UTC offset using getTimezoneOffset(). You can make
use of AJAX to update the UI and to collect this kind of info.

But the main thing is why do you need this kind of information?
This topic is locked and can not be replied to.