Given this base date:
base_date = \"10/29 06:58 AM\"
I want to find a tuple within the list that contains the closest date to the bas
bas
import datetime fmt = '%m/%d %H:%M %p' d = datetime.datetime.strptime(base_date, fmt) def foo(x): return (datetime.datetime.strptime(x[0],fmt)-d).total_seconds() > 0 sorted(list_date, key=foo)[-1]