I'd like to convert this string into a datetime object:
Wed Oct 20 16:35:44 +0000 2010
Is there a simple way to do this? Or do I have to write a RE to parse the elements, convert Oct to 10 and so forth?
EDIT: strptime is great. However, with
datetime.strptime(date_str, "%a %b %d %H:%M:%S %z %Y")
I get
ValueError: 'z' is a bad directive in format '%a %b %d %H:%M:%S %z %Y'
even though %z seems to be correct.
EDIT2: The %z tag appears to not be supported. See http://bugs.python.org/issue6641. I got around it by using a timedelta object to modify the time appropriately.