views:

996

answers:

1

I am parsing RSS feeds with the format as specified here: http://www.feedparser.org/docs/date-parsing.html

date tuple (2009, 3, 23, 13, 6, 34, 0, 82, 0)

I am a bit stumped at how to get this into the MySQL datetime format (Y-m-d H:M:S)?

+7  A: 
tup = (2009, 3, 23, 13, 6, 34, 0, 82, 0)
import datetime 
d = datetime.datetime(*(tup[0:6]))
#two equivalent ways to format it:
dStr = d.isoformat(' ')
#or
dStr = d.strftime('%Y-%m-%d %H:%M:%S')
vartec
Perfect, thankyou.
NeonNinja