I am getting
time data '2015-02-10T13:00:00Z' does not match format '%Y-%m-%d %H:%M:%S'
I tried:
import datetime
datetime.datetime.strptime('2015-02-10T13:00:00Z', '%Y-%m-%d %H:%M:%S')
and
import time
time.strptime('2015-02-10T13:00:00Z', '%Y-%m-%d %H:%M:%S')
what am I doing wrong?
As a quick workaround, you could add T
and Z
characters into the datetime formatting:
import datetime # v note v
datetime.datetime.strptime('2015-02-10T13:00:00Z', '%Y-%m-%dT%H:%M:%SZ')
# datetime.datetime(2015, 2, 10, 13, 0) # ^ note ^
But it's better to use something that is able to parse ISO-formatted date & time. For example, dateutil.parser
:
import dateutil.parser
dateutil.parser.parse('2015-02-10T13:00:00Z')
# datetime.datetime(2015, 2, 10, 13, 0, tzinfo=tzutc())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With