this question has answer here:
- python format timedelta string 19 answers
my database table has column datatype datetime
, when queried returns hh:mm:ss
. however, using python returns (datetime.timedelta(0, 57360),)
.
this time difference in seconds. how convert returned object string in format hh:mm
?
that's how can print time:
import datetime delta = datetime.timedelta(0, 57360) sec = delta.seconds hours = sec // 3600 minutes = (sec // 60) - (hours * 60) print(hours, ':', minutes)
you can print time seconds by
print(str(delta))
Comments
Post a Comment