0

We are often interested in obtaining the client's time zone (ex: America/Los_Angeles), for obvious reasons. Unfortunately, this isn't directly available within any widely used browser that I know of. Instead, we have to rely on asking the user, or attempting to detect it - with reasonable accuracy - using some Javascript that examines various date offsets (ex: jstz as described here).

My questions is, why not? Obviously the offset is available, which is based on the time zone. It would save the headache of having to use hacks to determine it, and of course one could always use other means to determine it with more confidence (ex: asking the user). Perhaps there are security implications, a lack of agreement in creating a standard solution, or something else I might be missing. I've done a lot of searching before posting this question and haven't found anything definitive.

Jeff Evans
  • 1,257
  • 1
  • 15
  • 31
  • jstz is one way, but there is also the ECMAScript Internationalization API option described in the dup post. – Matt Johnson-Pint Feb 05 '15 at 23:18
  • Respectfully, this is a different question than the one you linked to. I am not asking "how," but rather "why." – Jeff Evans Feb 05 '15 at 23:51
  • 2
    Sure, but you ask why it *isn't* available, but it is - via the new API: `Intl.DateTimeFormat().resolvedOptions().timeZone` – Matt Johnson-Pint Feb 06 '15 at 02:53
  • 1
    You are right though about there being a lack of a standard solution. Even through this API, it only *recommends* that IANA time zones be used. (See the note at the very bottom of [this section of the spec](http://www.ecma-international.org/ecma-402/1.0/#sec-12.3.2)). The general fact is - there is not yet an *official* standard for time zones. Though IANA time zones are treated as a *defacto* standard, they aren't official in the same way that ISO, IETF, or W3C standards are. – Matt Johnson-Pint Feb 06 '15 at 02:58
  • And from a practical perspective, that API is not yet available on all browsers. For example, Internet Explorer supports the Internationalization API, but returns `undefined` for this particular part of it. – Matt Johnson-Pint Feb 06 '15 at 03:00
  • 2
    So it sounds like the answer to my question, then, is that it's a known gap, and the various parties that be are working on it, but it hasn't been standardized/widely implemented yet. – Jeff Evans Feb 09 '15 at 16:25

0 Answers0