- Js Timezone List
- Moment Js Timezone List
- 2016-12-24: Minor bugfix in the countdown demo to make it work a bit more reliable in Firefox.
Load the library
Add the following HTML snippet to the <head>-section of your HTML page.
Optionally change some settings
Load and use timezones
Finally load and use one or more timezones. The timezones are specified using the well known names from the Olson database and can be loaded either synchronous or asynchronous. It's often simpler to use the synchronous interface, but it should be avoided if you use a lot of timezones that ain't cached already.
The asynchronous interface uses a call-back function.
Warning to users of Microsoft Windows
Microsoft is notoriously bad at keeping track of transition times between 'standard time' and 'summer time'. Users of Microsoft Windows should therefore be warned against using the 'localtime' time zone if they plan to use timestamps outside the current year.
Problems are VERY likely to show up! You have been warned!
As an example of the problem, let's compare the 'Europe/London' timezone and what Microsoft Windows users located in the UK will see if they use the 'localtime' time zone.
England ran an experiment in which they used GMT+1 the entire time between October 27th 1968 and October 31st 1971, i.e. 'summer time' all the time.
Epoch (timestamp=0) is defined as '1970-01-01 T 00:00:00.000 UTC'. Converted using the 'Europe/London' timezone that's '1970-01-01 T 01:00:00.000 BTS'. Note that the hours is '01' and the timezone abbreviation is 'BST', i.e. 'British Summer Time'.
Unfortunately for Microsoft Windows users in the UK, timestamp=0 will be converted to '1970-01-01 T 00:00:00.000' if they use the 'localtime' time zone. As you can see, the hours is '00', which is clearly wrong.
You're also more than welcome to run the code on Apple Mac OS, Linux or one of the BSDs. Neither of them should have any problems.
List of timezones
Js Timezone List
To get a list of (some of) the supported timezones, you can use this:
Due to the problem with Microsoft Windows mentioned above, 'localtime' was removed from the default list of time zones on November 22nd 2013.
You can still use the 'localtime' time zone, if you really want to, it just won't show up in any auto-generated list (e.g. drop-down menus) unless you actively take steps to make it so.
- Daylight Savings Time transitions are fully supported.
Moment Js Timezone List
Demos and examples
- Time compare
Show the same point in time in multiple timezones. You can go back and forth in time (keep the buttons pressed to move faster through time) and change the timezones.
- Timezone overview
You can add and remove timezones on the fly. The selected timezones are stored in a cookie, so you get the same list of timezones next time you load the page.
- World map
A Google Map with 415 timezone markers. Hover over a marker to see the current time at that location. Click a marker to keep the info window open. It's possible to drag the map and zoom in and out.
- Convert localtime
Convert localtime time in one timezone to localtime in another timezone. Uses the strptime() function to parse the localtime in the first timezone and the strftime() function to show the localtime in the other timezone.
- Simple canvas clock
A simple analog clock drawn using HTML canvas.
- Simple SVG clock
Another simple analog clock. This one is using SVG.
- Analog clock
Same as above, but the SVG is in a file by itself, which should make it easier to replace the graphics with a 'prettier' version.
- Analog clock 2
Just to demonstrate how easy it is to replace the graphics. This one also shows the date, time, timezone abbreviation and timezone as text.
- IP based
Use the geolocation API from IP-API.com to find the users timezone. Then display a simple clock using that timezone.
Select a timezone and set an alarm in the given timezone. When the alarm goes off a message will be displayed or an URL will be loaded.
You're only allowed to use the library, if you load it from this site as specified under Load the library above.
The data files are created by a simple conversion from the official tzdata. Since the original data from tzdata are public domain, so are the converted data files.
If you have any questions about the library, you're welcome to contact us:
- Twitter: @tzdatajs
If you think this project is useful, you're more than welcome to donate:
- Bitcoins: 16P7ANsjD47bRaKyPwsBdoXSH2Q1mKSX8c