from datetime import datetime as dt
fmt = '%a %d %b %Y %H:%M:%S %z'
for i in range(int(input())):
print(int(abs((dt.strptime(input(), fmt) - dt.strptime(input(), fmt)).total_seconds())))
Asked
Active
Viewed 261 times
-1

Błotosmętek
- 12,717
- 19
- 29

yogesh sirsat
- 13
- 1
- 2
-
Looks like you enter a number of iterations. Then enter 2 datetimes in the given format. Then it prints the difference between the 2 times in seconds. – 001 Mar 06 '20 at 18:06
1 Answers
0
First, you enter a number - that's how many timestamp pairs you'll be asked to enter.
Then, you enter those timestamps, one at a time. They must be in the same format, as defined by fmt
: weekday day month year hour:minute:second timezone - for example: Fri, 6 Mar 2020 19:06:06 CET.
For every pair of timestamps, the difference between them (in seconds) is computed and printed.

Błotosmętek
- 12,717
- 19
- 29