How should I fix this?
error is:
ValueError: time data '2016-10-20 03:43:11+00:00' does not match format '%Y-%m-%d %H:%M:%S%z'
code is:
fmt = "%Y-%m-%d %H:%M:%S%z"
dt = datetime.strptime(row['Time'], fmt)
How should I fix this?
error is:
ValueError: time data '2016-10-20 03:43:11+00:00' does not match format '%Y-%m-%d %H:%M:%S%z'
code is:
fmt = "%Y-%m-%d %H:%M:%S%z"
dt = datetime.strptime(row['Time'], fmt)
a bit of search would give you some nice solutions.
first option:
from datetime import datetime as dt
t = '2016-10-20 03:43:11+00:00'
fmt = "%Y-%m-%d %H:%M:%S+00:00"
d = dt.strptime(t, fmt)
# output datetime.datetime(2016,10,20,3,43,11)
second option:
from dateutil import parser as psr
t = '2016-10-20 03:43:11+00:00'
d = psr.parse(t)
# output datetime.datetime(2016,10,20,3,43,11, tzinfo=tzutc())