>>> from datetime import datetime >>> m2 = '1:35 PM' >>> in_time = datetime.strptime(m2, "%I:%M %p") >>> out_time = datetime.strftime(in_time, "%H:%M") >>> print(out_time) 13:35