Format time string in Python 3.3

time.localtime returns time.struct_time which does not support strftime-like formatting.

Pass datetime.datetime object which support strftime formatting. (See datetime.datetime.__format__)

>>> import datetime
>>> '{0:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now())
'2014-02-07 11:52:21'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)