попробовать:
from datetime import *
time1 = "12:00PM - 2:00PM"
# Splitting the string into two parts (using the hyphen in between them) and storing them in two separate variables
# t1 = start time; t2 = end time
t1, t2 = time1.split(" - ")
# string manipulation to make the data feedable to datetime.strptime()
t1 = t1.replace("AM", " AM").replace("PM", " PM")
t2 = t2.replace("AM", " AM").replace("PM", " PM")
# passing the data stored in our strings and converting it into 24hr format
t1 = datetime.strptime(t1, '%I:%M %p')
t1 = datetime.strftime(t1, "%H:%M")
t2 = datetime.strptime(t2, '%I:%M %p')
t2 = datetime.strftime(t2, "%H:%M")
print(t1)
print(t2)
выход:
12:00
14:00