How do I get the modified date/time of a file in Python?
2 Answers
os.path.getmtime(filepath)
or
os.stat(filepath).st_mtime
1 Comment
endolith
@endolith: stackoverflow.com/a/237082/125507 says "os.path.getmtime() is made for this, and simpler."
Formated:
import time
print time.strftime("%m/%d/%Y %I:%M:%S %p",time.localtime(os.path.getmtime(fname)))
1 Comment
Gringo Suave
ISO-like fmt:
"%Y-%m-%d %I:%M:%S %p"