Zachary Ware added the comment:
This is a documented peculiarity of the %p format code, see the '%p' entry in
the table at [1], note 3 in particular.
>>> from datetime import datetime
>>> datetime.strptime('1:00 PM', '%H:%M %p').hour
1
>>> datetime.strptime('1:00 PM', '%I:%M %p').hour
13
[1]
New submission from Andrew Page:
##
## It appears that strptime is ignoring the AM/PM field
##
from datetime import datetime
d1 = datetime.strptime("1:00 PM", "%H:%M %p")
d2 = datetime.strptime("1:00 AM", "%H:%M %p")
d1.hour, d2.hour
(1, 1) # d1 should be 13
d1 == d2
True # and these should not