0

The time duration is being described using four sets of double digits numbers separated with columns such as 00:02:01:16. I know that this represents a time interval or a time duration. I would like to translate it to a single number that represents a time duration in a more common form such as "120 seconds" or "12 minutes". What approach should be taken here?

1

2 Answers 2

1
", ".join((a+b for a,b in zip(time_s.split(":")," hour(s), min(s), second(s), ms".split(","))))
Sign up to request clarification or add additional context in comments.

Comments

0

You need to use timedelta.

from datetime import timedelta

Assume your time 00:02:01:16 is stored in a, which comes from end_time - start_time

This will be automatically be a timedelta object. Then you can use a.total_seconds() to get the seconds information.

Check Timedelta Documentation for more usage and examples

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.