formated local time

Looney, James B james.b.looney at lmco.com
Thu Nov 15 13:05:19 EST 2007


You could use:

import time
time.strftime( "%Y-%m-%d %H:%M:%S" ) 
or
time.strftime( "%Y-%m-%d %H:%M:%S", time.localtime() ) 

Output:
'2007-11-15 11:02:34'

Both strftime calls are equivalent, in this case.

> -----Original Message-----
> From: python-list-bounces+james.b.looney=lmco.com at python.org 
> [mailto:python-list-bounces+james.b.looney=lmco.com at python.org
> ] On Behalf Of Nikola Skoric
> Sent: Thursday, November 15, 2007 8:20 AM
> To: python-list at python.org
> Subject: formated local time
> 
> I have been trying to find appropriate way to do get local time in
> "yyyy-mm-dd hh:mm:ss" format, but the best I got is this:
> datetime.datetime.fromtimestamp(time.mktime(time.localtime()))
> It seems to me I'm missing a much simpler method, am I?
> 
> -- 
> "Now the storm has passed over me
> I'm left to drift on a dead calm sea
> And watch her forever through the cracks in the beams
> Nailed across the doorways of the bedrooms of my dreams"
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 



More information about the Python-list mailing list