Jun-16-2021, 10:30 PM
(This post was last modified: Jun-16-2021, 10:36 PM by Gribouillis.)
You could use pathlib and datetime modules
>>> from pathlib import Path >>> import datetime as dt >>> >>> yesterday = dt.datetime.now().date() - dt.timedelta(days=1) >>> f = Path('foo.png') >>> if yesterday == dt.datetime.fromtimestamp(f.stat().st_mtime).date(): ... print('f was last modified yesterday') ... >>>Note that st_mtime gives modification time on all platforms, and st_ctime gives creation time in Windows but not necessarily in Linux.