Created
August 10, 2022 13:22
-
-
Save Park-Developer/8434f3f09f819db15d694913d3c63a88 to your computer and use it in GitHub Desktop.
Calculate Time Interval
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_timeGap(start_time: str, end_time: str, time_format) -> str: | |
time_1 = datetime.strptime(start_time, time_format) | |
time_2 = datetime.strptime(end_time, time_format) | |
time_interval = time_2 - time_1 | |
hour_gap, min_gap = divmod(time_interval.seconds, 3600) | |
time_gap = { | |
"days": time_interval.days, | |
"hour": hour_gap, | |
"min": min_gap // 60 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`time_format="%Y-%m-%d %H:%M:%S"
time_1 = '2022-08-10 22:10:49'
time_2 = '2022-08-13 23:12:49'
test=calc_timeGap(time_1,time_2,time_format)
print(test)`