tzlocal: Local Time Zone Information for Python
A Python module that provides the local time zone information as a tzinfo object. Current version: 5.3.1, released on March 5, 2025. Maintained under the MIT License. Requires Python 3.9 or higher. Release cadence: approximately every 6 months.
Warnings
- breaking Version 5.0 removed pytz_deprecation_shim, returning only zoneinfo objects. For pytz compatibility, use version 4.0.
- gotcha get_localzone_name() may raise an error if no time zone name is configured on Unix systems. Use get_localzone() if only the tzinfo object is needed.
Install
-
pip install tzlocal
Imports
- get_localzone
from tzlocal import get_localzone
Quickstart
from tzlocal import get_localzone local_timezone = get_localzone() print(local_timezone)