os.stat - time format conversion + md5

Klaus Alexander Seistrup jakabov119 at magnetic-ink.dk
Tue Dec 17 10:02:29 EST 2002


DP wrote:

> how do I convert the output of os.stat(some_filename) to "plain"
> understandable time format, i.e. DD/MM/YYYY HH:MM:SS.

time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(os.stat(some_filename)[-2]))

will give you mtime in the requested format.  Use -1 instead of -2
if you want ctime.

> I'd rather be able to compare creation/modification dates

Why not compare "seconds since epoch", which is what you get from
os.stat(some_filename)[-2], rather than going through the hazzle
of converting those seconds to a human readable format?


  // Klaus

-- 
 ><> 	vandag, môre, altyd saam



More information about the Python-list mailing list