You are viewing a single comment's thread. Return to all comments →
hours, minutes, seconds_period=s.split(":") seconds, period=seconds_period[:2], seconds_period[2:] hours=int(hours) if period=='PM' and hours!=12: hours+=12 elif period=='AM' and hours==12: hours=0 military_time='{:02d}:{:02d}:{:02d}'.format(hours, int(minutes), int(seconds)) return military_time
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →
hours, minutes, seconds_period=s.split(":") seconds, period=seconds_period[:2], seconds_period[2:] hours=int(hours) if period=='PM' and hours!=12: hours+=12 elif period=='AM' and hours==12: hours=0 military_time='{:02d}:{:02d}:{:02d}'.format(hours, int(minutes), int(seconds)) return military_time