Re: [Tutor] can time.time() be reversed so as to get date?
by Vince Spicer other posts by this author
Nov 6 2009 10:17AM messages near this date
[Tutor] can time.time() be reversed so as to get date?
|
Re: [Tutor] can time.time() be reversed so as to get date?
On Fri, Nov 6, 2009 at 10:30 AM, Shashwat Anand <anand.shashwat@[...].com> wrote:
> If I have been given the number of seconds from midnight 1970.01.01 GMT,
> can I calculate the date, month and time in the following format : 'Fri Nov
> 6 9:58:16 2009' ?
>
> _______________________________________________
> Tutor maillist - Tutor@[...].org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
Sure,
you can get datetime from a teimstamp
EX:
from datetime import datetime
import time
now = time.time()
date = datetime.fromtimestamp(now)
print date.strftime("%a %b %d %H:%M:%S %Y")
Vince
Thread:
Shashwat Anand
Vince Spicer
Alan Gauld
Alan Gauld
Alan Gauld
Timo
Shashwat Anand
Luke Paireepinart
Shashwat Anand
Dave Angel
|