The following program calculates the days, minutes and seconds between two dates. To calculate the seconds, the total_seconds()
method is called through the timedelta object.
from datetime import datetime
today = datetime(2022,12,15)
bday = datetime(2023,3,20)
difference = bday - today
print(str(difference) + " days until your birthday")
print(str(difference.total_seconds()/60) + " minutes until your birthday")
print(str(difference.total_seconds()) + " seconds until your birthday")
95 days, 0:00:00 days until your birthday
136800.0 minutes until your birthday
8208000.0 seconds until your birthday