Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Time Converter (12h to 24h) by zalikovka
def time_converter(t12):
#assign comfortable variables
hours, mins=t12[:-8], t12[-7:-5]
#a.m.
if t12[-4]=='a':
#if 12 hours exсeption
if hours=='12':
t24='00'+':'+mins
else:
#if hours don`t have 2 digits add '0'
if len(hours)==2:
t24=hours+':'+mins
else:
t24='0'+hours+':'+mins
#p.m.
else:
#if 12 hours exсeption
if hours=='12':
t24='12'+':'+mins
else:
t24=str(int(hours)+12)+':'+mins
return t24
June 19, 2018