SIMPLER TIMEZONES
a zero-dependency package that returns all major timezones,
with tools for guessing the nearest timezone to a user
the two major problems this library solves are:
you may want to use this library if:
you should not use this library if:
import { SimplerTimezones } from 'simpler-timezones';
const simplerTimezones = new SimplerTimezones();
import { SimplerTimezones } from 'simpler-timezones';
const simplerTimezones = new SimplerTimezones({ showMoreTimezones: true });
simplerTimezones.getTimezones();
//[
// {
// name: '[-11:00] Samoa Standard Time (SMST)',
// token: 'utc-11',
// show_by_default: true,
// offset_standard: -1100,
// primary_locales: ['Pacific/Samoa'],
// locales: [
// 'Etc/GMT+11',
// 'Pacific/Midway',
// ...
simplerTimezones.getTimezone(-800);
//{
// name: '[-08:00] Pacific Standard Time (PT)',
// token: 'utc-8',
// show_by_default: true,
// offset_standard: -800,
// primary_locales: [ 'America/Los_Angeles' ],
// locales: [
// 'America/Ensenada',
// ...
note: works on all major browsers (chrome/safari/firefox/edge), doesn't work on internet explorer
simplerTimezones.guessTimezone();
//{
// name: '[-08:00] Pacific Standard Time (PT)',
// token: 'utc-8',
// show_by_default: true,
// offset_standard: -800,
// primary_locales: [ 'America/Los_Angeles' ],
// locales: [
// 'America/Ensenada',
// ...
offset | name | primary locales | shown in default view |
---|---|---|---|
[-11:00] | Samoa Standard Time (SMST) | Pacific/Samoa | false |
[-10:00] | Hawaiian Standard Time (HAST) | Pacific/Honolulu | true |
[-09:30] | Marquesas Time (MART) | Pacific/Marquesas | false |
[-09:00] | Alaskan Standard Time (AK) | America/Anchorage | true |
[-08:00] | Pacific Standard Time (PT) | America/Los_Angeles | true |
[-07:00] | Mountain Standard Time (MT) | America/Denver | true |
[-06:00] | Central Standard Time (CT) | America/Chicago | true |
[-05:00] | Eastern Standard Time (ET) | America/New_York | true |
[-04:00] | Atlantic Standard Time (AST) | America/Caracas | true |
[-03:30] | Newfoundland Standard Time (NST) | America/St_Johns | false |
[-03:00] | Argentina Standard Time (ART) | America/Buenos_Aires, America/Sao_Paulo | true |
[-02:00] | South Georgia Time (GST) | Atlantic/South_Georgia | false |
[-01:00] | Cape Verde Standard Time (CVT) | Atlantic/Azores, Atlantic/Cape_Verde | true |
[+00:00] | GMT Standard Time (GMT) | Europe/London | true |
[+01:00] | Central European Time (CET) | Europe/Paris | true |
[+02:00] | Egypt Standard Time (EGST) | Africa/Cairo | true |
[+03:00] | Russian Standard Time (MSK) | Asia/Baghdad, Europe/Moscow | true |
[+03:30] | Iran Standard Time (IRST) | Asia/Tehran | true |
[+04:00] | Arabian Standard Time (ARBST) | Asia/Dubai | true |
[+04:30] | Afghanistan Standard Time (AFT) | Asia/Kabul | true |
[+05:00] | Pakistan Standard Time (PKT) | Asia/Karachi | true |
[+05:30] | India Standard Time (IST) | Asia/Kolkata | true |
[+05:45] | Nepal Time (NPT) | Asia/Kathmandu | true |
[+06:00] | Central Asia Standard Time (BTT) | Asia/Dhaka | true |
[+06:30] | Myanmar Time (MMT) | Asia/Rangoon | true |
[+07:00] | SE Asia Standard Time (THA) | Asia/Bangkok | true |
[+08:00] | China Standard Time (CST) | Asia/Hong_Kong, Asia/Shanghai | true |
[+09:00] | Tokyo Standard Time (TST) | Asia/Tokyo, Asia/Seoul | true |
[+09:30] | AUS Central Standard Time (ACST) | Australia/Adelaide | true |
[+10:00] | AUS Eastern Standard Time (AEST) | Australia/Sydney | true |
[+11:00] | Central Pacific Standard Time (SBT) | Asia/Magadan, Pacific/Guadalcanal | true |
[+12:00] | New Zealand Standard Time (NZST) | Pacific/Auckland | true |
[+12:45] | Chatham Island Standard Time (CHAST) | Pacific/Chatham | false |
[+13:00] | Tonga Standard Time (TOT) | Pacific/Tongatapu, Pacific/Apia | false |
[+14:00] | Line Islands Time (LINT) | Pacific/Kiritimati | false |
here are two examples illustrating why this isn't an accurate timezone library:
America/Phoenix
. technically, there is a timezone specifically for the state of Arizona, in which Phoenix is located, because Arizona is on "Mountain Time" but does not observe daylight saving. however, since we're presenting a reasonable list of timezones, we don't differentiate between "Mountain Time" and "Mountain Time (Arizona)". based on their "standard time" offset, their nearest guess will be Mountain Time, and this library will not assist with selecting Mountain Time (Arizona), nor will it assist with telling you whether the user in Phoenix is currently at offset -6:00 or -7:00. you'll have to use other libraries and methods to do that.showMoreTimezones: true
option to it, since some low-population and many unique-offset timezones are not shown by default.choosing a single name for a time offset that spans many countries is inherently an editorial decision with political undertones. choosing which timezones to leave out of the default list is as well. decisions are guided as follows:
showMore
option is set to true
.for more information on source data, please see ./source/data-for-humans
.