[Tutor] can time.time() be reversed so as to get date?

vince spicer vinces1979 at gmail.com
Fri Nov 6 18:55:15 CET 2009


On Fri, Nov 6, 2009 at 10:30 AM, Shashwat Anand <anand.shashwat at gmail.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 at python.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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091106/28a9904b/attachment.htm>


More information about the Tutor mailing list