Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Time
Date
Datetime
10. Datetime arithmetic
Summary

Instruction

Good job! We can find the difference between two datetime objects, just as we did with date objects:

fra_mad_actual = datetime.datetime(2018, 12, 1, 9, 45, 0)
now = datetime.datetime.today()
timedelta = now - fra_mad_actual
print('Time since my FRA-MAD flight:', timedelta)

The resulting string will differ based on the moment when you execute the code.

Exercise

Write a function named starts_in(start_datetime). The function should accept a datetime and return a timedelta that shows how much time is left until the meeting starts. In your solution, assume that start_datetime is in the future, never in the past.

Stuck? Here's a hint!

Inside the function, define a variable named now:

now = datetime.datetime.today()

Then, calculate the time difference between start_datetime and now.