How to calculate the differences between two dates in seconds with Python

1 Answer

0 votes
import datetime
 
d1 = datetime.datetime(2021, 6, 19)
d2 = datetime.datetime(2021, 6, 21)
 
seconds = abs(d1 - d2).total_seconds()
print(seconds)


 
 
 
'''
run:
 
172800.0
 
'''

 



answered Jun 22, 2021 by avibootz
...