I'm trying to get the difference between two time-stamps: 1606294772889
and 1606295867656
. But I keep getting OSError: [Errno 22] Invalid argument
Here is my code:
from datetime import datetime
def get_duration(start , end):
fmt = '%Y-%m-%d %H:%M:%S'
start = datetime.utcfromtimestamp(start).strftime(fmt)
end = datetime.utcfromtimestamp(end).strftime(fmt)
tstamp1 = datetime.strptime(start, fmt)
tstamp2 = datetime.strptime(end, fmt)
if tstamp1 > tstamp2:
td = tstamp1 - tstamp2
else:
td = tstamp2 - tstamp1
td_mins = int(round(td.total_seconds() / 60))
print('The difference is approx. %s minutes' % td_mins)
get_duration(start = 1606294772889 , end = 1606295867656)
Traceback:
Traceback (most recent call last):
File "c:/Users/Yas_!_ru/Documents/GitHub/Mindustry-Ranked/webdriver.py", line 220, in <module>
Match.get_duration(start = 1606294772889 , end = 1606295867656)
File "c:/Users/Yas_!_ru/Documents/GitHub/Mindustry-Ranked/webdriver.py", line 207, in get_duration
start = datetime.utcfromtimestamp(start).strftime(fmt)
OSError: [Errno 22] Invalid argument