datetime also has the strftime method:

import datetime
datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')

- Adam

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
Behalf
> Of [EMAIL PROTECTED]
> Sent: Thursday, November 15, 2007 9:56 AM
> To: python-list@python.org
> Subject: Re: formated local time
> 
> On Nov 15, 7:19 am, Nikola Skoric <[EMAIL PROTECTED]> wrote:
> > 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?
> 
> 
> If you want the formatted string, you can use strftime:
> 
> >>> time.strftime("%Y-%m-%d %H:%M:%S")
> '2007-11-15 07:51:12'
> 
> --
> Hope this helps,
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to