1

I am trying to make the timedelta to display time in H:M:S:MS format , i am able to display in H:M:S format using datetime.timedelta function like below

 print((datetime.timedelta(minutes=500)))

output: 8:20:00

How can i get the output as 8:20:00:00 in H:M:S:MS

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
computernoob
  • 420
  • 4
  • 18

2 Answers2

2

One way to go is using string formating:

d = datetime.timedelta(minutes=500)
print('%s:%s' % (str(d), d.microseconds))
# 8:20:00:0
Chris
  • 29,127
  • 3
  • 28
  • 51
1

You can add one:

print(str(datetime.timedelta(minutes=500))+':0')

Output:

8:20:00:0
U13-Forward
  • 69,221
  • 14
  • 89
  • 114