The time method of datetime module
The time method of the datetime module creates a time object. In the first parameter of the method we specify the hours, in the second parameter - the minutes, in the third - the seconds.
Syntax
import datetime
datetime.time(hours, minutes, seconds)
Example
Let's create a new time object:
import datetime
res = datetime.time(12, 59, 59)
print(res.hour)
print(res.minute)
print(res.second)
The result of the executed code:
12
59
59
See also
-
method
dateof moduledatetime,
which creates a new object with a date -
method
todayof moduledatetime,
which returns the current date -
method
nowof moduledatetime,
which returns the current time -
method
datetimeof moduledatetime,
which creates a date and time object -
method
strftimeof moduledatetime,
which creates a formatted string with date and time