strptime

Parse a string into a datetime object.

from datetime import datetime
s = '2024-01-15 14:30'
dt = datetime.strptime(s, '%Y-%m-%d %H:%M')