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

U12-Forward
  • 65,118
  • 12
  • 70
  • 89
Techiesoft
  • 376
  • 2
  • 16

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
  • 27,139
  • 3
  • 23
  • 44
1

You can add one:

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

Output:

8:20:00:0
U12-Forward
  • 65,118
  • 12
  • 70
  • 89