Overview:
-
The class method utcnow() from the datetime class Python standard library returns the current time in UTC.
-
The returned datetime object does not have the tzinfo attribute set.
-
The fold attribute of DateTime object is set to zero and is not writable. Apart from the string of the form 2025-07-29 14:08:55.601448 that can be used for recreating other purposes the DateTime object returned is a timezone naive object.
Example:
# Example Python program that gets the # import the datetime module # Get UTC time using datetime class print("Datetime attributes:") # The following line will result in an AttributeError
|
Output:
UTC now: |