There is an example located at How do I find the time difference between two datetime objects in python?
It uses
def check_time_difference(t1: datetime, t2: datetime):
as in
def check_time_difference(t1: datetime, t2: datetime):
t1_date = datetime(
t1.year,
t1.month,
t1.day,
t1.hour,
t1.minute,
t1.second)
t2_date = datetime(
t2.year,
t2.month,
t2.day,
t2.hour,
t2.minute,
t2.second)
t_elapsed = t1_date - t2_date
return t_elapsed
I'm wondering, is there a way to convert that first line so that it works with Python 2? In Python 2, I get an error that says
def check_time_difference(t1: datetime, t2: datetime):
SyntaxError: invalid syntax
It works fine in Python 3.