Inferring timezone for HTTP headers

Hello,

I am encountering the classic ‘hosting timezone different from customer
timezone’ problem. The hosting timezone is CST, but users all over the
world are visiting the site.

I understand I can make the Timezone selection a user preference and use
TZInfo (http://tzinfo.rubyforge.org/) to do the math.

But, is there anyway to infer the client timezone from the HTTP headers
or the request object?

Thanks,
+Veera.

I am encountering the classic ‘hosting timezone different from customer
timezone’ problem. The hosting timezone is CST, but users all over the
world are visiting the site.

I understand I can make the Timezone selection a user preference and use
TZInfo (http://tzinfo.rubyforge.org/) to do the math.

But, is there anyway to infer the client timezone from the HTTP headers
or the request object?

Not in Firefox 2.0 on the mac at least… I don’t think I’ve ever heard
of this anywhere though… would be a nice feature though.

Philip H. wrote:

I am encountering the classic ‘hosting timezone different from customer
timezone’ problem. The hosting timezone is CST, but users all over the
world are visiting the site.

I understand I can make the Timezone selection a user preference and use
TZInfo (http://tzinfo.rubyforge.org/) to do the math.

But, is there anyway to infer the client timezone from the HTTP headers
or the request object?

Not in Firefox 2.0 on the mac at least… I don’t think I’ve ever heard
of this anywhere though… would be a nice feature though.

Thanks for your reply Philip.

Yes, it would be a great feature. Perhaps, we should place a request to
firefox-dev to add this in their future releases. Once firefox does this
everyone else will follow - just like all the other nice features in
firefox.

Anyone know whats the best channel to do that?

You could do this by getting the user’s ip, doing a location lookup and
then matching the country/state with a timezone. It would be a bit
inaccurate (esp. since some cities run on timezones different to the
rest of the state/province).

jdswift wrote:

You could do this by getting the user’s ip, doing a location lookup and
then matching the country/state with a timezone. It would be a bit
inaccurate (esp. since some cities run on timezones different to the
rest of the state/province).

Thanks.

But, I dont think it will work - 2 issues:

  1. Doing this for every single client (since the value could be saved in
    the session handle for subsequent requests) will make it prohibitively
    expensive.
  2. I only know websites that can do this lookup. How to do this
    programmatically? Once, I get a city/country name for the IP, how can
    that be programmatically mapped to a timezone? I do not have any idea if
    this is even possible! :frowning:

Seems like the cost/pain is much more than the benefit. I would rather
add a TIMEZONE user preference instead of doing this.

But how to cache your pages if you have to compute the time/date for
every user?
I dunno anything about your website, but relative time (10 minutes ago,
1 hour ago…) ala gmail might be an option to solve the cache/user pref
pb. You just have to time-out the cache every ten minutes or so and
compute the elapsed time is very easy in rails.Yet if your app is an
agenda like application, just forget everything I said.

Anyone know whats the best channel to do that?
Probably won’t happen… even if Firefox did it, that’s what only 20% of
the users… until IE does it, it’s not reliable… and even then isn’t
reliable until everyone upgrades…

Oh well :confused:

You could use javascript to transform the date into the client’s
timezone.
This post on _why’s blog describes how to go about doing this:
http://redhanded.hobix.com/inspect/showingPerfectTime.html

Hammed

Benoit B. wrote:

But how to cache your pages if you have to compute the time/date for
every user?
I dunno anything about your website, but relative time (10 minutes ago,
1 hour ago…) ala gmail might be an option to solve the cache/user pref
pb. You just have to time-out the cache every ten minutes or so and
compute the elapsed time is very easy in rails.Yet if your app is an
agenda like application, just forget everything I said.

this is a good tip! thanks!

Hammed M. wrote:

You could use javascript to transform the date into the client’s
timezone.
This post on _why’s blog describes how to go about doing this:
http://redhanded.hobix.com/inspect/showingPerfectTime.html

Hammed

This is it, I think - promises to do exactly what I want. I will give it
a shot and update here if it works. Cheers!