formated local time
attn.steven.kuo at gmail.com
attn.steven.kuo at gmail.com
Thu Nov 15 10:56:06 EST 2007
On Nov 15, 7:19 am, Nikola Skoric <nick-n... at net4u.hr> 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
More information about the Python-list
mailing list