I was using :
total_time=datetime.time(int(total_time_text.replace("h","").replace("m","").split(" ")[0]),int(total_time_text.replace("h","").replace("m","").split(" ")[1]),0)
to store the time length.
But when I have :
total_time_text ="26h 50m"
I get an exception that
'hour must be in 0..23'
so the type "time" is not properly for this var. What I must to use?
Python Basic date and time types Sr.No. Datatypes & Description 1 date It is date type object. It uses Gre ... 2 time It is a time object class. It is in ... 3 datetime It is a combined set of dates a ... 4 timedelta It is used to express the diff ... 2 more rows ...
Time module in Python provides various time-related functions. This module comes under Python’s standard utility modules. time.time () method of Time module is used to get the time in seconds since epoch.
Often, we may want to measure a span of time, or a duration, using Python datetime. We can do this with its built-in timedelta class. A timedelta object represents the amount of time between two dates or times.
To manipulate dates and times in the python there is a module called datetime. There are two types of date and time objects. The types are naïve and the aware. In the naïve object, there is no enough information to unambiguously locate this object from other date-time objects.
datetime.timedelta
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With