In Python, you can use the os.path.getmtime(path) to get the file’s last modified timestamps. This method will returns the time in seconds since the epoch.
import os import datetime last_modified_sec = os.path.getmtime('wildlife.jpg') last_modified_date = datetime.datetime.fromtimestamp(last_modified_sec) print("Last modified in seconds:", last_modified_sec) print("Last modified date:", last_modified_date)
Output
Last modified in seconds: 1560368140.686942 Last modified date: 2019-06-12 15:35:40.686942