Comparing dates to check for old files
now = time.time()
twodays_ago = now - 60*60*24*2 # Number of seconds in two days
if fileCreation < twodays_ago:
print "File is more than two days old"
I know, it is an old question. But I was looking for something similar and came up with this alternative solution:
from os import path
from datetime import datetime, timedelta
two_days_ago = datetime.now() - timedelta(days=2)
filetime = datetime.fromtimestamp(path.getctime(file_path))
if filetime < two_days_ago:
print "File is more than two days old."