Overview
- The class atrribute utc returns a timezone object which has the offset and name set for the UTC.
Example
# Example Python program that gets the
# timezone object of UTC from the timezone class attribute
# timezone.utc
from datetime import timedelta, timezone, time
# Get the UTC timezone object
utc = timezone.utc
# Get the offset
offset = utc.utcoffset(None)
# Get the name
name = utc.tzname(None)
# Print UTC information
print(name)
print(offset)
print(type(utc))Output
UTC
0:00:00
<class 'datetime.timezone'>