Extracting time from a timedelta

0 votes
How can I get time from a datetime.timedelta object in Python?
Aug 13, 2019 in Python by Fata
• 1,050 points
1,699 views

1 answer to this question.

0 votes

Use the following piece of code:

import datetime
a = datetime.timedelta(0, 3600)
print((datetime.datetime.min + a).time())

OUTPUT:

01:00:00
answered Aug 13, 2019 by Wajiha
• 1,960 points
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP