Reputation: 175
I am trying to parse a string to a datetime field but it raises the following error:
ValueError: time data '15 Dec 1995 00:00 AM' does not match format '%d %b %Y %I:%M %p'
I have checked the python documents and I don't see where the format mismatch is happening. Can anyone help me find where this format error is?
Upvotes: 1
Views: 223
Reputation: 3369
Looking at the docs:
%I
Hour (12-hour clock) as a zero-padded decimal number.
01, 02, …, 12
So 00:00:00
is not a valid time under the %I
format, given that 00:00:00 AM
should actually be 12:00:00 PM
Upvotes: 2
Reputation: 188
There is no 00:00 time in 12-hour clock format, you should either write this as 12:00 or use a 24-hour format with %H.
Upvotes: 1