pytz is a Python library that brings the IANA/Olson timezone database into the Python runtime, enabling accurate, cross-platform timezone calculations for all the world’s timezones. It addresses a major limitation of Python’s built-in datetime.tzinfo by providing consistent support for daylight-saving transitions, historical offset changes, and ambiguous times (such as the end of DST). With pytz, developers can convert naïve datetime objects into timezone-aware ones, shift between timezones, and safely perform arithmetic across DST boundaries with methods like localize() and normalize(). Although Python 3.9 and newer include better built-in timezone support (via zoneinfo and external packages like tzdata), pytz remains widely used—especially in legacy codebases or in environments where backward compatibility matters.
Features
- Full implementation of the IANA/Olson timezone database in Python
- Methods to localize naïve datetimes and to normalize timezone transitions (especially around DST)
- Lists of supported timezones (all_timezones, common_timezones) and country-to-timezones mappings
- Works across a broad range of Python versions, including legacy 2.x and early 3.x versions
- MIT-licensed, well-tested and mature library designed for production use
- Clear API for timezone conversion, offset handling, and safe arithmetic in timezone-aware contexts
License
MIT License
MongoDB Atlas runs apps anywhere
Deploy in 115+ regions with the modern database for every enterprise.
MongoDB Atlas gives you the freedom to build and run modern applications anywhere—across AWS, Azure, and Google Cloud. With global availability in over 115 regions, Atlas lets you deploy close to your users, meet compliance needs, and scale with confidence across any geography.
Start Free