Q: finding distance between 2 time's
Anders J. Munch
2009 at jmunch.dk
Sat May 30 07:52:17 EDT 2009
jkv wrote:
> Hi Martin,
>
> What i usally do is to convert the two times to seconds since epoch and
> compare the two values in seconds. You can use time.mktime to convert
> localtime to seconds since epoch.
There's no need to convert - simply retrieve the times as absolute times to
begin with:
file_age_in_seconds = time.time() - os.path.getmtime(filename)
Only convert to local time for presentation.
- Anders
More information about the Python-list
mailing list