It looks like datetime.datetime.strptime(d, '%a, %d %b %Y %H:%M:%S %z') should work, but according to this error report there are problems processing %z . Therefore, you probably have to process the time zone yourself:
import datetime d = u"Fri, 16 Jul 2010 07:08:23 -0700" d, tz_info = d[:-5], d[-5:] neg, hours, minutes = tz_info[0], int(tz_info[1:3]), int(tz_info[3:]) if neg == '-': hours, minutes = hours * -1, minutes * -1 d = datetime.datetime.strptime(d, '%a, %d %b %Y %H:%M:%S ') print d print d + datetime.timedelta(hours = hours, minutes = minutes)
Chris B.
source share