Convert timestamps with offset to datetime obj using strptime
The Python 2 strptime() function indeed does not support the %z format for timezones (because the underlying time.strptime() function doesn’t support it). You have two options: Ignore the timezone when parsing with strptime: time_obj = datetime.datetime.strptime(time_str[:19], ‘%Y-%m-%dT%H:%M:%S’) use the dateutil module, it’s parse function does deal with timezones: from dateutil.parser import parse time_obj = parse(time_str) … Read more