The isoformat()
method gives you that:
d.isoformat(' ')
but might include microsends; you could use the .strftime()
method for some more control:
d.strftime('%Y-%m-%d %H:%M:%S')
Output
>>> import datetime
>>> d = datetime.datetime.today()
>>> d.isoformat(' ')
'2013-01-26 13:12:08.628580'
>>> d.strftime('%Y-%m-%d %H:%M:%S')
'2013-01-26 13:12:08'