How do I determine the systems Olson zoneinfo in JavaScript?

2024/2/27 7:10:05

I'm interested in retrieving the current zoneinfo string ("America/Los Angeles", "Europe/London", etc.) that the user currently has set for their OS in JavaScript. I've found how to get the current offset in seconds, offsets at specific dates, and less exact time zones (PST, etc.) but not the Olson zoneinfo. Is this possible?

Answer

I worked on this very issue a couple of months back and the result is this: http://site.pageloom.com/automatic-timezone-detection-with-javascript. The script will not give you the most precise result possible. For example, it will return Europe/Berlin regardless of where in the Central European timezone you are.

Basically all it does it check for known dates when daylight saving transitions take place.

Hopefully it will help.

http://en.ppmy.cn/q/42879.html

Related Q&A

Using javascript to write an iframe for a widget - best practices / limitations?

Im in the middle of development of a third-party widget of sorts (an HTML5/js video player), designed to be embeddable on third-party sites seamlessly, which works in conjunction with a Flash player (t…

Load image from URL and upload to media library in Strapi

Im building a CSV importer for my Strapi application and one of its task is to read an image URL from a cell and download it from the URL and save it to media library. The code looks like this: const r…

How to pass PHP array parameter to Javascript Function?

index.php<script type="text/javascript" src="javascript.js"> </script> <?php$movies = array("Bloodsport", "Kickboxer", "Cyborg", "…

continuous movement animation with jquery

continuous movementI would like to recreate the truck moments in the above site , It is done in mootools. How would I code this, is there a jQuery plugin to do this?So animate an object from beginning…

Javascript wildcard variable?

The value of product_id might be some combination of letters and numbers, like: GB47NTQQ.I want to check to see if all but the 3rd and 4th characters are the same.Something like:if product_id = GBxxNTQ…

FOR loop performance in Javascript [duplicate]

This question already has answers here:For-loop performance: storing array length in a variable(6 answers)Closed 7 years ago.As my research leads me to believe that for loops are the fastest iteration …

TypeError: Assignment to constant variable

Please help me solve the error. I have attached my index.js code routes.js code and db.js code and the error description. Ive been trying hard to solve the error.index.jsconst express = require(express…

jQuery ajax, wait until beforeSend animation finishes

HTML & CSS:<a href="#">link</a> <img src="http://2.bp.blogspot.com/_OIHTbzY7a8I/TOaiTKLqszI/AAAAAAAAAHM/eb3iiOqxzKg/s640/Auto_Audi_Audi_concept_car_005130_.jpg" /…

Setting window.location.href of the current tab in a browser_action Chrome Extension

Im trying to navigate the current tab to a URL in a browser_action Chrome extension, in response to a keyword that a user has entered. Whats the best way to do this?First I tried a simple form with ja…

Angular bootstrap modal causing strict-di error, not sure why

Weird problem, using Angular UI bootstrap modal I have no issues at all with Angular 1.3 beta 16, however if I enable ng-strict-di mode I get the following error:Error: [$injector:strictdi] function($s…