Compare 2 times
Alain Ketterlin
alain at dpt-info.u-strasbg.fr
Wed Jun 6 10:03:52 EDT 2012
Alain Ketterlin <alain at dpt-info.u-strasbg.fr> writes:
> loial <jldunn2000 at gmail.com> writes:
>
>> I have a requirement to test the creation time of a file with the
>> current time and raise a message if the file is more than 15 minutes
>> old.
>> Platform is Unix.
>> I have looked at using os.path.getctime for the file creation time and
>> time.time() for the current time, but is this the best approach?
>
> No. getctime() returns the last "change" time. The creation time is not
> kept anywhere. This may still match your requirement though. And os.path
> is the right package to look at for such tasks.
Sorry, it may happen that the filesystem you're working with provides
that time, in which case it's called birthtime. This _may_ be available
via os.stat().
-- Alain.
More information about the Python-list
mailing list