import datetime
today = datetime.datetime.today()
modified_date = datetime.datetime.fromtimestamp(os.path.getmtime('yourfile'))
duration = today - modified_date
How to see if file is older than 3 months in Python?