Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Mixed formatting solution in Clear category for Time Converter (24h to 12h) by kkkkk
from datetime import datetime
def time_converter(time_str):
"""Convert time from 24-hour to 12-hour format."""
dt_obj = datetime.strptime(time_str, '%H:%M')
am_or_pm = 'a.m.' if dt_obj.hour < 12 else 'p.m.'
return dt_obj.strftime(f'%I:%M {am_or_pm}').lstrip('0')
Sept. 15, 2019