DateTime.tzinfo()
The datetime.now()
does not have any information about the time zones. It just uses the current system time. In some situations, the time zone details may be needed. In such cases the tzinfo abstract class is used. tzinfo is an abstract base class. It cannot be instantiated directly. A concrete subclass has to derive it and implement the methods provided by this abstract class.
The instance of the tzinfo class can be passed to the constructors of the datetime and time objects. It finds its applications in situations such as the conversion of local time to UTC or to account for daylight saving time.
Python – datetime.tzinfo()
The DateTime class provides various functions to manipulate the date and time intervals. The DateTime object which you use in datetime.now()
is actually the object of the DateTime class. These objects help us use the functions on dates and times.
Note: For more information, refer to Python datetime module with examples