[issue26321] datetime.strptime fails to parse AM/PM correctly

Zachary Ware report at bugs.python.org
Tue Feb 9 10:59:54 EST 2016


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] https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior

----------
nosy: +zach.ware
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26321>
_______________________________________


More information about the Python-bugs-list mailing list