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: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED]
> ] On Behalf Of Nikola Skoric
> Sent: Thursday, November 15, 2007 8:20 AM
> To: python-list@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
> 
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to