In Python, there are several ways to calculate date and time. There are some in-built modules used to determine the date and time. The name of such modules is given below which are used to determine date and time.
This module is used to work with both date and time. It is an in-built module. This module has different classes which are very much helpful to determine date and time. In python, datetime is an object and it is an immutable type.
datetime.date
: This class mainly follows the current Gregorian calendar and attributes of this class are year, month, and day.datetime.time
: This class assumes that each day of a year has 24*60*60 seconds and attributes of this class are the microsecond, second, minute, hour, and tzinfo.datetime.datetime
: It is used to determine both date and time and attributes are the microsecond, second, minute, hour, day, month, and year.datetime.timedelta
: This class is used to determine the difference between two different dates or two times and all this operation is done in a microsecond.datetime.tzinfo
: This is an abstract base class that is used to provide the information object about a different time zone.datetime.timezone
: This class implements the tzinfo class as a fixed offset from UTC.Constants: The datetime module exports two types of constant. These two types of constants are:
Datetime.MINYEAR
: This constant allows the minimum or the smallest number of years in a datetime object. By default, the value of MINYEAR is 1.Datetime.MAXYEAR
: This constant allows the maximum or the largest number of years in a datetime object. By default, the value of MAXYEAR is 9999.This module is basically works on only time. The three main attributes of time are second, minute, and hour. This module has some built-in functions. The descriptions of those functions are given below.
This module is also an inbuilt module in python that is used to determine calendars related problems. This module is very important and this module works on year, month, and days of a week. This module has some built-in functions. The descriptions of those functions are given below.