Python: get file last modified
import os.path, time, datetime
file_path = "path/to/file.txt"
string_date_format = "%a %b %d %H:%M:%S %Y"
# Get last modified
string_date = time.ctime(os.path.getmtime(file_path)
print(string_date)
# Convert last modified string to datetime
datetime_date = datetime.datetime.strptime(string_date, string_date_format)
print(datetime_date)