4

I tried it on webapps but it wasn't well-received there. I realize now that it's intended for power users of webapps, so not appropriate.

To me, it almost doesn't belong on Stack Overflow itself because there (probably) isn't a concrete answer. If there was, I suspect I would have found it after a long time I spent on web searches before asking.

Any tips would be appreciated

Why is the client time zone (not just offset) not available in the browser? [Closed]

Editors note: The referred question was deleted by Community user as RemovedAbandonedClosed, below is the body:

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 the browser. 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. But why not the time zone itself? 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 client). Are there security implications, or a lack of interest in creating a standard solution, or something else I might be missing?

8
  • To poke holes: what browser are you talking about? We are all acutely aware that every browser does different things in regards to its supported functions...
    – Makoto
    Jan 14, 2015 at 22:33
  • Very true. This answer hints at some browser-specific support but doesn't mention any specifics. I suspect if any did, then browser-unification tools like jQuery would support it. stackoverflow.com/a/18252251/375670
    – Jeff Evans
    Jan 14, 2015 at 22:42
  • 3
    This looks like a question for Super User, but I strongly suspect the answer to it is "because time zones aren't consistent". Jan 14, 2015 at 22:50
  • I'd upvote your question but I don't know about others. @KevinBrown Where in the page does it say that?
    – simonzack
    Jan 14, 2015 at 22:59
  • I don't think the inconsistency of time zone definitions, itself, is relevant to my question. The point is there is a setting somewhere in the operating system for time zone, which for all practical purposes is a string (however weird or inconsistent that string value), and it's exposed in a half-working way through the browser. Why not just let the browser have the string value?
    – Jeff Evans
    Jan 14, 2015 at 23:01
  • 4
    I'm voting to close this question as off-topic because we can't evaluate the question anymore.
    – Makoto
    Jan 4, 2017 at 15:07
  • @rene: Yes, that seems fair.
    – Makoto
    Jan 4, 2017 at 19:27
  • 2
    Similar, if not duplicate (yes, asked after this one, but it has many more votes than this): meta.stackoverflow.com/q/323334/215552 Jan 4, 2017 at 21:54

1 Answer 1

3

I'm afraid non of the sites within the Stack Exchange Network will be a good fit for the question in its current state.

Although it seems nicely disguised as a technical question the answers will be mostly opinion based and/or hearsay unless the user that answers the question was present at the design meeting JavaScript and/or the standards body that now governs its development.

It seems however a reasonable question, if asked well (and assuming it isn't a duplicate). So why wouldn't you reword this and explain the difficulties you have to detect the timezone. You can show some of the workarounds you have in place and then demonstrate with a small MCVE that correct detection fails. Your can then ask if there is solution to this problem.

The answers might confirm what you already concluded: the specifications lack any support so you're on your own, or someone has a nice library that covers all corner-cases, or you overlooked a simple solution. In the extra ordinary case you'll get background on the reasons why it was designed this way, anecdotal or not.

2
  • Just for posterity, it seems that this is now available via ECMAScript internationalization features, as per: stackoverflow.com/a/34602679/375670 Intl.DateTimeFormat().resolvedOptions().timeZone
    – Jeff Evans
    Feb 18, 2021 at 17:07
  • 1
    @JeffEvans well, that was about time it got a spec and an implementation...
    – rene
    Feb 18, 2021 at 17:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .