How to calculate the time interval between two time strings

前端 未结 12 2625
生来不讨喜
生来不讨喜 2020-11-22 12:03

I have two times, a start and a stop time, in the format of 10:33:26 (HH:MM:SS). I need the difference between the two times. I\'ve been looking through documentation for

12条回答
  •  执念已碎
    2020-11-22 12:48

    Both time and datetime have a date component.

    Normally if you are just dealing with the time part you'd supply a default date. If you are just interested in the difference and know that both times are on the same day then construct a datetime for each with the day set to today and subtract the start from the stop time to get the interval (timedelta).

提交回复
热议问题