Determine user agent timezone offset without using javascript?

Is there a way to determine the timezone for a user agent without javasript?

usually, I would execute this javascript fragment:

<script type="text/javascript" language="JavaScript"> var offset = new Date(); document.write('<input type="hidden" id="clientTzOffset" name="clientTzOffset" value="' + offset.getTimezoneOffset() + '"/>'); </script> 

However, for many mobile phones and JS clients, either nonexistent or disabled. Is there anything clever that I can do, or was it all about “telling me where you are and what you do?”

+4
source share
4 answers

Perhaps with the language on the server side, you can search by IP address, and then determine from your country what time zone they can be in.

I would suggest that this could be problematic.

If you go down this road, this question (and answers) may be helpful.

Getting location from IP address

+2
source

Use both options. Set javascript as default for list or text field. The percentage of people without javascript is so small that the load is tiny.

I was going to say “Use Date header: header”, but only the response header seems.

+5
source

I was thinking of a different solution, but it is a bit complicated. Configure some fake HEAD requests with a max-age: 1 response header to force the browser to intercept them. Then you should get the if-modified-since header from any modern browser, for example:

 If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT 

Just be careful not to send the last corrected headers with the first answer, because

For best results when sending an If- Modified message. Since the header field is for checking the cache, clients are advised to use the exact date string obtained in the previous Last- Modified header field when possible.

Note the “whenever possible” disclaimer. This and other parts of the header description imply that the client will use its own clock when it knows nothing about the servers.

With the right combination of headers, this can work very well.

EDIT: I tried some tests with FF, but could not find the correct combination of headers to run if-modified-since during client time. FF sends only the header if it received the previously modified header earlier, and then it simply reflects the value back (even if it is not a valid date).

+3
source

I saw a website where, instead of asking what time zone the user was in, he simply asked “choose the right time,” and he showed them a list of times. This is a subtle difference from “what time zone you are in,” but much easier to understand. Sorry, I can no longer find the site

+1
source

All Articles