> Subject:
> Re: [Tutor] deleting files that are older than x days old
> From:
> Kent Johnson <[EMAIL PROTECTED]>
> Date:
> Wed, 13 Jul 2005 13:50:47 -0400
> 
> CC:
> tutor@python.org
> 
> 
> Mike Hansen wrote:
> 
>> How do you convert a time represented in seconds from the epoch into a 
>> datetime object?
> 
> 
> Use datetime.datetime.fromtimestamp():
> 
>  >>> import os, datetime
>  >>> t=os.path.getmtime('build.xml')
>  >>> t
> 1115045692
>  >>> d=datetime.datetime.fromtimestamp(t)
>  >>> d
> datetime.datetime(2005, 5, 2, 10, 54, 52)
> 
> Kent
> 

The docs for fromtimestamp weren't clear to me. i.e. not spelling it out that 
it 
converts from seconds from the epoch(which must be the POSIX timestamp it's 
referring to).

Thanks! And thanks to the others that replied on how to do this without using 
datetime.

Mike
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to