I'm having an issue parsing dates in python and I cant figure out what I'm doing wrong. I looked at a bunch of tutorials and I think I'm positively lost.
Here is what im trying to parse and the error that I am getting: the code:
when = datetime.datetime.strptime(dateOfBirth, " %Y-%m-%dT%I:%M:%S")
the error:
time data ' 1909-04-01T00:00:00Z' does not match format ' %Y-%m-%dT%I:%M:%S'
CodePudding user response:
This is how it should be formatted:
when = datetime.datetime.strptime(dateOfBirth,' %Y-%m-%dT%H:%M:%SZ')
CodePudding user response:
This works, and keeps the timezone.
when = datetime.datetime.strptime(dateOfBirth, " %Y-%m-%dT%H:%M:%S%z")