tzlocal
tzinfo object for the local timezone
Decision gist · record as of 2026-08-14
Yes. tzlocal is actively maintained, has no known vulnerabilities, minimal dependencies, and solves a genuine gap in Python's standard library. It's in the top 1000 PyPI packages by download volume and supports current Python versions. Install it if you need to work with local timezone information in any application.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- On Unix systems, get_localzone_name() may fail if no timezone is configured, though get_localzone() will generally succeed.
- Low install friction with a single runtime dependency (tzdata).
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions, making it suitable for most projects without licensing concerns.
last release 2026-06-29 (46 days) · last repo commit 2026-06-29 · 221 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 225,531,993 downloads/mo, #184 on PyPI
Alternatives
Verify before relying
pip install tzlocal
from tzlocal import get_localzone
tz = get_localzone()
print(tz) # zoneinfo.ZoneInfo(key='Europe/Warsaw')- Whether tzdata is automatically installed as a dependency or must be installed separately on all platforms
- Performance characteristics when called repeatedly or in high-frequency scenarios
What it is and what it does
tzlocal solves the problem of detecting the local system timezone without requiring you to know or manually specify the IANA timezone name. It returns a zoneinfo.ZoneInfo object (or just the timezone name string) by inspecting system configuration files like /etc/timezone, /etc/localtime, and platform-specific registry entries on Windows. This fills a gap in Python's standard library, where pytz and zoneinfo provide no built-in way to discover the local timezone.
The package handles the messy reality of timezone configuration across Unix variants and Windows, gracefully degrading to UTC when no configuration is found and providing detailed debug output to help diagnose misconfigured systems. Version 5.0 returns only zoneinfo objects (dropping pytz compatibility from version 4.0), making it compatible with modern Python's timezone handling. It's not for converting current time to UTC—use the standard time module for that—but for working with timezone-aware datetimes in the past or future.
Use it for
- Initialize a timezone-aware datetime with local timezone info without hardcoding the timezone name
- Convert timestamps between local timezone and other timezones for historical or future dates
- Detect the system's configured timezone name for logging, configuration, or display purposes
- Build cross-platform applications that need to respect the user's local timezone setting
- Troubleshoot timezone configuration issues in Docker or other containerized environments
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
tzlocal is actively maintained, has no known vulnerabilities, minimal dependencies, and solves a genuine gap in Python's standard library. It's in the top 1000 PyPI packages by download volume and supports current Python versions. Install it if you need to work with local timezone information in any application.
Install
tzlocal on PyPI
Before you install
Low install friction with a single runtime dependency (tzdata). Actively maintained with a recent release 46 days ago and ongoing repository activity. Supports modern Python versions (3.10 through 3.14) and is marked as Mature.
Requires Python 3.10 or later. On Unix systems, get_localzone_name() may fail if no timezone is configured, though get_localzone() will generally succeed.
License in practice
MIT license permits commercial and private use with minimal restrictions, making it suitable for most projects without licensing concerns.
Quickstart
pip install tzlocal
from tzlocal import get_localzone
tz = get_localzone()
print(tz) # zoneinfo.ZoneInfo(key='Europe/Warsaw')
Verify before relying
- Whether tzdata is automatically installed as a dependency or must be installed separately on all platforms
- Performance characteristics when called repeatedly or in high-frequency scenarios
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagetzdata |
| Maintenance | Actively maintained 46 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 225,531,993 / month, #184 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 6 - MatureOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: UnixProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Typing :: Typed |
Evidence: tzlocal-5.4.4-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “local timezone detection”
- tzlocalReturns the IANA timezone name and tzinfo object for the local system…
- airporttimeConverts between local time and UTC for any airport by IATA code,…
- local-crontabConverts crontab expressions from a local timezone into…
Give your agent the search over MCP, or paste the wish link into any chat.
Similar packages
pytz brings the Olson timezone database into Python, enabling accurate timezone calculations and conversions across platforms with support for daylight saving time transitions.
Provides access to the Olson timezone database for Python, allowing you to read timezone files and query their paths without external dependencies.
However, it is dormant—no active maintenance since 2020—so if you need current timezone updates or expect ongoing support, verify alternatives first.
Provides IANA time zone data as a Python package, serving as a fallback when system time zone information is unavailable or not in a standard location.
Provides drop-in timezone shims that support both the standard PEP 495 datetime interface and pytz's legacy localize/normalize methods, allowing libraries to deprecate pytz gradually.
Provides IANA time zone support for Python 3.6–3.8 by backporting the standard library's `zoneinfo` module, enabling timezone-aware datetime handling with automatic daylight-saving transitions.
However, if you are already on Python 3.9+, use the standard library `zoneinfo` instead.
Converts geographic coordinates (longitude/latitude) to timezone names using simplified polygon data, with optional GeoJSON export for visualization.
See also airporttime · django-timezone-field · tzwhere · aiozoneinfo