How to calculate the differences between two dates in Python

1 Answer

0 votes
import datetime
 
d1 = datetime.datetime(2021, 5, 7, 12, 00)
d2 = datetime.datetime(2021, 6, 21, 15, 00)
 
print(abs(d2 - d1))
 
 
 
 
'''
run:
 
45 days, 3:00:00
 
'''

 



answered Jun 21, 2021 by avibootz
...