In python how do I sum up the following time?
0:00:00 0:00:15 9:30:56
Use the timedelta() class from the datetime module to add minutes to datetime, e.g. result = dt + timedelta(minutes=10) .
It depends on the form you have these times in, for example if you already have them as datetime.timedelta
s, then you could just sum them up:
>>> s = datetime.timedelta(seconds=0) + datetime.timedelta(seconds=15) + datetime.timedelta(hours=9, minutes=30, seconds=56) >>> str(s) '9:31:11'
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