Skip to main content

countrystatecity-timezones

PyPI Python Version License Type Checked timezones timezones

Official Python package for 432 IANA timezones with country associations, GMT offsets, and time conversion utilities. Part of the countrystatecity ecosystem.

From offline prototype to production

This package provides a versioned offline snapshot. For regularly updated data, server-side search and filtering, field-selected responses, or managed availability and support, use the Country State City API through its official Python client:

pip install countrystatecity-api
from countrystatecity import CountryStateCity

csc = CountryStateCity()          # reads CSC_API_KEY

Get a free API key · API docs · Pricing · Migration guide

Keep API keys in server-side environment variables, never in client-side code or source control.

Installation

pip install countrystatecity-timezones

Quick Start

from countrystatecity_timezones import (
    get_all_timezones,
    get_timezones_by_country,
    get_timezone_by_zone_name,
    get_timezones_by_offset,
    search_timezones,
    convert_time,
)
from datetime import datetime

# Get all timezones
timezones = get_all_timezones()
# [Timezone(zoneName="Africa/Abidjan", gmtOffset=0, ...), ...]

# Get timezones for a country
us_timezones = get_timezones_by_country("US")
# [Timezone(zoneName="America/Adak", countryCode="US", ...), ...]

# Lookup by IANA zone name
tz = get_timezone_by_zone_name("America/New_York")
# Timezone(zoneName="America/New_York", gmtOffset=-18000, gmtOffsetName="UTC-05:00", ...)

# Filter by GMT offset (seconds)
utc_minus_5 = get_timezones_by_offset(-18000)

# Search by name or abbreviation
results = search_timezones("Eastern")

# Convert time between timezones
dt = datetime(2024, 1, 1, 12, 0, 0)
converted = convert_time(dt, "America/New_York", "Asia/Kolkata")
# datetime(2024, 1, 1, 22, 30, tzinfo=ZoneInfo("Asia/Kolkata"))

Data Model

class Timezone(BaseModel):
    zoneName: str        # IANA timezone name (e.g., "America/New_York")
    gmtOffset: int       # GMT offset in seconds (e.g., -18000)
    gmtOffsetName: str   # Human-readable offset (e.g., "UTC-05:00")
    abbreviation: str    # Timezone abbreviation (e.g., "EST")
    tzName: str          # Full timezone name (e.g., "Eastern Standard Time")
    countryCode: str     # ISO2 country code (e.g., "US")
    countryName: str     # Country name (e.g., "United States")

API Reference

Function Description
get_all_timezones() Get all timezone entries
get_timezones_by_country(code) Get timezones for an ISO2 country code
get_timezone_by_zone_name(name) Lookup by IANA zone name
get_timezones_by_offset(seconds) Filter by GMT offset in seconds
search_timezones(query) Search by zone name, full name, or abbreviation
convert_time(dt, from_tz, to_tz) Convert datetime between IANA timezones

License

ODbL-1.0 — see LICENSE.

Other Packages in this Ecosystem

Package Description
countrystatecity-api Official API client — live data, sync + async, typed
countrystatecity-countries 250 countries, 5,308 states, 171,938 cities
countrystatecity-currencies 249 country/currency associations
countrystatecity-translations 4,724 translations in 19 languages
countrystatecity-phonecodes International phone/dialing codes for 250 countries
countrystatecity-regions Region and subregion associations for 250 countries
countrystatecity-postal-codes Postal/ZIP records for 125 countries

Data sourced from countries-states-cities-database.


Made with ❤️ by dr5hn

Metadata

Release files for countrystatecity-timezones 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for countrystatecity-timezones 2.0.1
File Size Uploaded
countrystatecity_timezones-2.0.1.tar.gz 18.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for countrystatecity-timezones 2.0.1
File Interpreter ABI Platform
countrystatecity_timezones-2.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 35.5 kB

Release files / countrystatecity_timezones-2.0.1.tar.gz

Download URL countrystatecity_timezones-2.0.1.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bf6c1ed01e0f092fd2c032ebeaa163e29d2896efedc9e7319a177973faa5192c
BLAKE2b-256 checksum
How to use checksums
d76d0dac001ebb80187bdcb9e724b9ed6365728c039d7d4a2591e39100e85d4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / countrystatecity_timezones-2.0.1-py3-none-any.whl

Download URL countrystatecity_timezones-2.0.1-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1205d2b47eecd1d794d5b3826c82965f1636eb6d63f68550bb7599784e23b7e
BLAKE2b-256 checksum
How to use checksums
02637b1f3c4186ccb1ce5fa48415b75b04bead80c564d213fd65032a5865d032
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page