datetime module
from datetime import datetime
timeIn12HourFormat = '5:30 PM'
dateTime = datetime.strptime(timeIn12HourFormat, '%I:%M %p')
timeIn24HourFormat = dateTime.strftime('%H:%M')
print(timeIn24HourFormat)
from datetime import datetime
timeIn12HourFormat = '5:30 PM'
dateTime = datetime.strptime(timeIn12HourFormat, '%I:%M %p')
timeIn24HourFormat = dateTime.strftime('%H:%M')
print(timeIn24HourFormat)
Leave a Comment
Cancel reply