On this page
article
Parse Datetime Strings
Convert date strings to datetime objects.
Category: datetime
Problem
Convert date strings to datetime objects.
Solution
dt = datetime.strptime("2026-06-13", "%Y-%m-%d")
Notes
- Adapt variable names and paths to your project
- Add error handling for production use
- See related chapters in the Learning Path