Python Practice › Datetime Programs › Program 3
Parse a date string
Write a Python program to convert the string “15/08/2026 09:30” into a datetime.
Output
2026-08-15 09:30:00 Saturday
Approach
datetime.strptime(text, format).
Solution
from datetime import datetime dt = datetime.strptime("15/08/2026 09:30", "%d/%m/%Y %H:%M")print(dt, dt.strftime("%A"))Output
2026-08-15 09:30:00 Saturday
Learn the concept
New to this topic? Read the lesson, then come back.