RepositoryJavaScript
kevalbhatt

kevalbhatt/timezone-picker

Select timezone using world map

101stars
40forks
15issues
1views

timezone-picker

timezone-picker is the plugin to select and get timezone value of selected area(country) from WorldMap.

NPM version NPM Dependency MIT Licence Open Source Love contributions welcome HitCount

Live Demo: http://kevalbhatt.github.io/timezone-picker/


Imgur

Dependency


  • moment-timezone
  • jquery
  • select2 (optional)

Installation


Use package Using npm

npm install --save timezone-picker

or

Use package Using CDN

Include the following lines of code in the section of your HTML.

 <!-- Optional -->

 

 <!-- Optional -->

Usage


Select any dom element where you want to create the map.

$(selector).timezonePicker();

defaultValue

Set a custom value on load

If defaultValue is null then system timezone is selected

  • Select value based on zonename.

$(selector).timezonePicker({ defaultValue: { value: "EAT", attribute: "zonename" }});
  • Select value based on country code.

$(selector).timezonePicker({ defaultValue: { value: "IN", attribute: "country" }});
  • Select value based on timezone.

$(selector).timezonePicker({ defaultValue: { value: "Asia/Calcutta", attribute: "timezone" }});
  • Select value based on offset.

$(selector).timezonePicker({ defaultValue: { value: "5.5", attribute: "offset" }});

You can create custom shortcuts link using quickLink options.

$(selector).timezonePicker({
    quickLink: [{
        "IST": "IST",
        "LONDON": "Europe/London"
    }]
});
  • "LONDON": This key is used as a display string for shortcut button.
  • "Europe/London": This value is used when user click on a button and based on value, map is highlighted

Example:

You can pass following value.

  • timezone : Europe/London
  • zonename : GMT
  • country code : GB
$(selector).timezonePicker({
    quickLink: [{
        "LONDON1": "Europe/London"
    }]
});

$(selector).timezonePicker({
    quickLink: [{
        "LONDON2": "GB"
    }]
});

$(selector).timezonePicker({
    quickLink: [{
        "LONDON3": "GMT"
    }]
});

$(selector).timezonePicker({
    quickLink: [{
        "GMT": "GMT"
    }]
});

hoverText

$(selector).timezonePicker({
    hoverText: function(e, data){
        return (data.timezone + " (" + data.zonename + ")");
    }
});

quickLinkClass

Class name for the quickLink container.

$(selector).timezonePicker({
    quickLinkClass: "quick-class"
});

Output

<div class="filter-box">
    <select class="country-lov select-class"></select>
+    <div class="quick-link quick-class"></div>
    <div class="hover-text"></div>
</div>

selectClass

Class name for the country drop-down.

$('body').timezonePicker({
    selectClass: "select-class"
});

Output

<div class="filter-box">
+    <select class="country-lov select-class"></select>
    <div class="quick-link"></div>
    <div class="hover-text"></div>
</div>

filterBoxClass

Class name for the filter box container.

$('body').timezonePicker({
    filterBoxClass: "filter-class"
});

Output

+<div class="filter-box filter-class">
    <select class="country-lov"></select>
    <div class="quick-link"></div>
    <div class="hover-text"></div>
</div>

hoverTextClass

Class name for the hover text container.

$('body').timezonePicker({
    hoverTextClass: "hover-class"
});

Output

<div class="filter-box">
    <select class="country-lov"></select>
    <div class="quick-link"></div>
+    <div class="hover-text hover-class"></div>
</div>

Options


ParameterTypeDefaultDescription
widthNumber500width of map
heightNumber250height of map
defaultValueObjectSystem timezoneSet custome value on load { value: "EAT", attribute: "zonename" }
quickLinkArray<Object>[{"IST": "IST","LONDON": "Europe/London"}]Creates shortcuts to select zone
quickLinkClassStringquick-linkquickLinkClass will be appended with the default value
filterBoxClassStringfilter-boxfilterBoxClass will be appended with the default value
selectBoxBooleantrueIf it is set to false select box will not be created
selectClassStringcountry-lovselectClass is appended with the default value
showHoverTextBooleantrueIf it is set to false hover text will not be shown
hoverTextFunctiontimezone(zonename)Called on hover of country (works only if showHoverText is true)
hoverTextClassStringhover-texthoverTextClass is appended with the default value
hoverTextElJquery selectorAppened in filter-boxhover text element is appended in selector
mapHoverTypeStringhover polygon(area)by default it will show hovered polygon(area) on which mouse is pointed other hover options

mapHoverType options

ParameterTypeDescription
timezoneStringwhen you hover on the map it will highlight all country with the same timezone
countryStringwhen you hover on the map it will highlight all country with same country code
zonenameStringwhen you hover on the map it will highlight all country with the same zone name

Methods


.setValue(value[String-required],attribute[String-optional])

Select the value(country) based on value and attribute parameter.

  • Set timezone string as a first parameter for example: 'Asia/Kolkata'.
  • Default attribute is "timezone";
$(selector).data('timezonePicker').setValue('Asia/Kolkata')
  • If you want to set value based on offset then set the 1st parameter as an offset string("5.5") and 2nd parameter to 'offset'
$(selector).data('timezonePicker').setValue('5.5','offset')
  • If you want to set value based country code then set the 1st parameter as country code and 2nd parameter to 'country'
$(selector).data('timezonePicker').setValue('IN','country')
  • If you want to set value based zonename then set the 1st parameter as zonename(IST) and 2nd parameter to 'zonename'
$(selector).data('timezonePicker').setValue('IST','zonename')

.getValue()

It returns object containing timezone details of seleted area:

$(selector).data('timezonePicker').getValue()

Sample returned Object

  [
    {
        "selected":true,
        "zonename":"IST",
        "offset":5.5,
        "pin":"361,115",
        "country":"LK",
        "timezone": "Asia/Colombo",
    },
    {
        "zonename":"IST",
        "offset":5.5,
        "pin": "373,94",
        "country":"IN",
        "timezone": "Asia/Kolkata",
    }
]

.getSystemTimezone()

It returns an object containing system timezone details.

.getTimeZoneObject(value[String-required],attribute[String-optional])

It returns an object containing timezone details based on value and attribute.

  • Get timezone Object using timezone string example: 'Asia/Kolkata'.
  • Default attribute is "timezone";
$(selector).data('timezonePicker').getTimeZoneObject('Asia/Kolkata');
  • If you want to get Object based on offset then set the 1st parameter as an offset string("5.5") and 2nd parameter to 'offset'
$(selector).data('timezonePicker').getTimeZoneObject('5.5','offset');
  • If you want to get Object based country code then set the 1st parameter as country code and 2nd parameter to 'country'
$(selector).data('timezonePicker').getTimeZoneObject('IN','country');
  • If you want to get Object based zonename then set the 1st parameter as zonename(IST) and 2nd parameter to 'zonename'
$(selector).data('timezonePicker').getTimeZoneObject('IST','zonename');

.getZoneName(value[String-required],attribute[String-optional])

It returns an zonename based on value and attribute.

  • Get zonename String using timezone string example: 'Asia/Kolkata'.
  • Default attribute is "timezone";
$(selector).data('timezonePicker').getZoneName('Asia/Kolkata');
  • If you want to get zonename based on offset then set the 1st parameter as an offset string("5.5") and 2nd parameter to 'offset'
$(selector).data('timezonePicker').getZoneName('5.5','offset');
  • If you want to get zonename based country code then set the 1st parameter as country code and 2nd parameter to 'country'
$(selector).data('timezonePicker').getZoneName('IN','country');

.getTimeZoneString(value[String-required],attribute[String-optional])

It returns an timezone string based on value and attribute.

  • Get timezone String using country code example: 'IN'.
  • Default attribute is "country";
$(selector).data('timezonePicker').getZoneName('IN');
  • If you want to get timezone string based on offset then set the 1st parameter as an offset string("5.5") and 2nd parameter to 'offset'
$(selector).data('timezonePicker').getTimeZoneString('5.5','offset');
  • If you want to get timezone string based zonename then set the 1st parameter as zonename(IST) and 2nd parameter to 'zonename'
$(selector).data('timezonePicker').getTimeZoneString('IST','zonename');

Events


map:loaded

As soon as the map is loaded and ready the map:loaded is fired. To catch it you can use:

$(selector).on("map:loaded" , function(){
    console.log("Map is loaded, have fun!");
});

map:value:changed

Whenever the value of the timezone changes, the event map:value:changed is fired. To catch it you can use:

$(selector).on("map:value:changed" , function(){
    console.log($(selector).data('timezonePicker').getValue());
});

map:country:clicked

Event map:country:clicked is fired, when a user clicks on the country. To catch it you can use:

$(selector).on("map:country:clicked" , function(){
    console.log($(selector).data('timezonePicker').getValue());
});

map:quickLink:clicked

Event map:quickLink:clicked is fired, when a user clicks on the quickLink button. To catch it you can use:

$(selector).on("map:quickLink:clicked" , function(){
    console.log($(selector).data('timezonePicker').getValue());
});

map:option:changed

Event map:option:changed is fired, when a user changes the value from the country drop-down. To catch it you can use:

$(selector).on("map:option:changed" , function(){
    console.log($(selector).data('timezonePicker').getValue());
});

License


It is available under the MIT LICENSE

Similar Projects

Discover other similar projects and AI models.

RepositoryTypeScript
vvo/tzdb

Always up to date IANA time zones for time zone pickers: grouped list with major cities, current offsets, DST abbreviations, and the country of any time zone. Updated daily.

917
Nov 26, 2026
RepositoryPython
jannikmi/timezonefinder

Offline timezone lookup for WGS84 coordinates, with no polygon simplification - so the answer stays correct at timezone borders.

541
Nov 24, 2026
RepositoryGo
ringsaturn/tzf

Get timezone via longitude and latitude in Go in a fast way

199
Dec 1, 2026
RepositoryPython
ringsaturn/tzfpy

Probably the fastest Python package to convert longitude/latitude to timezone name.

143
Nov 2, 2026
RepositoryC++
HowardHinnant/date

A date and time library based on the C++11/14/17 <chrono> header

3.4k
Nov 24, 2026
Repository
fawazahmed0/cloudflare-trace-api

Get IP Address, TimeStamp, User Agent, Country Code, IATA, HTTP Version, TLS/SSL Version & more by Cloudflare

196
Aug 20, 2024
RepositorySwift
gligorkot/TimeZonePicker

A TimeZonePicker UIViewController similar to the iOS Settings app. Search and select from a range of cities and countries to find your most suitable time zone.

122
Aug 5, 2020
RepositoryRust
ringsaturn/tzf-rs

Get timezone via longitude&latitude in Rust in a fast way

112
Nov 2, 2026
RepositoryJavaScript
jquery/jquery

jQuery JavaScript Library

60.1k
Dec 2, 2026