There are several modules in Python to express the time.
Module time
Time access and conversions.
Module datetime
More object-oriented interface to dates and times. Provides the
time
anddatetime
types with which theZoneInfo
class is designed to be used.
Module zoneinfo
The zoneinfo
module provides a concrete time zone implementation to support the IANA time zone database.
from zoneinfo import ZoneInfo
import datetime
dt = datetime.datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles"))
Module calendar
General calendar-related functions. timegm() is the inverse of gmtime() from this module.
Package dateutil
Third-party library dateutil provides powerful extensions to datetime
module with expanded time zone and parsing support.
Module locale
Internationalization services. The locale setting affects the interpretation of many format specifiers in strftime() and strptime.