Possible Duplicate:
python: which file is newer & by how much time
In python — how do I check — if the file is newer then some other file?
Edit:
There are creation time and modification time.
The question should state the desired property explicitly.
Modification
-
os.stat(FILE).st_mtime -
os.path.getmtime(FILE)
Creation
os.path.getctime(FILE) and os.stat(FILE).st_ctime doesn’t give creation time on Unix-like OSes. Link by root has the solution on how to find out the creation time on Unix-like boxes.
You can also use
os.path.getctime. This example will returnTrueiffile1was created beforefile2andFalseotherwise.EDIT: Note that there is no cross platform solution to your question — ctime() in Unix means last change time, not create time. The same applies when using os.stat(file).st_ctime.
Here seems to be something that could work on unix machines.