PyDocs

Nav

Data Types

date.strptime

datetime

classmethod of date · Added in 3.14
  • date.strptime(date_string, format)
Parse string according to the given date format (like time.strptime()).

For a list of supported format codes, see the documentation:
    https://docs.python.org/3/library/datetime.html#format-codes
1 Example
>>> import datetime as dt
>>> date_string = "02/29"
>>> when = dt.date.strptime(f"{date_string};1984", "%m/%d;%Y")  # Avoids leap year bug.
>>> when.strftime("%B %d")
'February 29'
from the Python docs
See Also
No see-alsos for datetime/date.strptime
0 Notes
No notes for date.strptime