Possible Duplicate:
Parse date and format it using python?
i have a date string like 2011-07-15 13:00:00+00:00
. Any way to convert this string to a datetime object in python ?
Thank You
Possible Duplicate:
Parse date and format it using python?
i have a date string like 2011-07-15 13:00:00+00:00
. Any way to convert this string to a datetime object in python ?
Thank You
You can use the strptime function in the datetime module. http://docs.python.org/library/datetime.html#strftime-and-strptime-behavior
datetime.datetime.strptime('2011-07-15 13:00:00', '%Y-%m-%d %H:%M:%S')
Edit:
Lesson learnt, the datetime module isn't capable of doing this, at least on my platform. Mu Mind's solution seems to be the easiest way to do this robustly according to http://wiki.python.org/moin/WorkingWithTime