tzlocal
tzinfo object for the local timezone
Install
tzlocal on PyPI
pip
pip install tzlocaluv
uv add tzlocalpoetry
poetry add tzlocalPackage facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — tzdata |
| Maintenance | actively maintained — 45 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: tzlocal-5.4.4-py3-none-any.whl
Keywords: timezone
About tzlocal
from the package's own PyPI description — quoted content, verbatim
tzlocal
API CHANGE!
With version 3.0 of tzlocal, tzlocal no longer returned pytz objects, but
zoneinfo objects, which has a different API. Since 4.0, it now restored
partial compatibility for pytz users through Paul Ganssle's
pytz_deprecation_shim.
tzlocal 4.0 also adds an official function get_localzone_name() to get only
the timezone name, instead of a timezone object. On unix, it can raise an
error if you don't have a timezone name configured, where get_localzone()
will succeed, so only use that if you need the timezone name.
4.0 also adds way more information on what is going wrong in your configuration when the configuration files are unclear or contradictory.
Version 5.0 removes the pytz_deprecation_shim, and now only returns
zoneinfo objects, like verion 3.0 did. If you need pytz objects, you have
to stay on version 4.0. If there are bugs in version 4.0, I will release
updates, but there will be no further functional changes on the 4.x branch.
Info
This Python module returns the IANA time zone name
<https://www.iana.org/time-zones>_ for your local time zone or a tzinfo
object with the local timezone information,...
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
Retrieves the local system timezone as a `zoneinfo.ZoneInfo` object or IANA timezone name, handling platform-specific configuration across Windows and Unix systems.
Low friction: pure-Python wheel with a single runtime dependency (tzdata). Active maintenance with a release 45 days ago and last commit in June 2026.
MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for any project context.
Usage
pip install tzlocal
from tzlocal import get_localzone
tz = get_localzone()
print(tz) # zoneinfo.ZoneInfo(key='Europe/Warsaw')
Requires Python 3.10 or later. On Unix systems, timezone detection may fail if the system lacks a configured timezone name, though get_localzone() will generally fall back to UTC.
Verdict: Mature, actively maintained library (14 years, top 1000 PyPI) with zero known vulnerabilities. Clean MIT license and minimal dependencies make it a reliable choice for applications needing local timezone detection across Windows and Unix platforms.
Needs verification
- Whether version 5.0's removal of pytz_deprecation_shim affects existing codebases relying on pytz compatibility.
- Performance characteristics when called repeatedly in high-frequency scenarios.
- Behavior on systems with ambiguous or misconfigured timezone setups beyond the documented Docker case.
Similar packages
permissive · top 100 on PyPI
pytzpermissive · top 100 on PyPI
tzdatapermissive · top 100 on PyPI
parsedatetimepermissive · top 1,000 on PyPI
annotated-typespermissive · top 100 on PyPI
pendulumpermissive · top 1,000 on PyPI
arrowpermissive · top 1,000 on PyPI
phonenumberspermissive · top 1,000 on PyPI
types-pytzpermissive · top 1,000 on PyPI
isodatepermissive · top 1,000 on PyPI