Jul-28-2021, 06:10 PM
My bad!
The time strings list has a bad format .
Sorry about that!
I made changes it seems it is forking now.
The time strings list has a bad format .
Sorry about that!
I made changes it seems it is forking now.
from datetime import datetime tms= ['2021-07-05-231403','2021-07-05-221402','2021-07-05-214001','2020-07-05-221400','2021-07-05-121404','2021-07-05-111405','2021-07-05-101406'] for et in tms : et=et.strip() hr = int(et[11:13]) if (hr <=12) : #print(f" AM - {hr}") d = datetime.strptime(et, "%Y-%m-%d-%H%M%S") d2 =(datetime.strftime(d, "%d/%m/%Y %I:%M:%S %p")) print(f" AM --> {d2}") if (hr >12) : #print(f" PM - {hr}") d = datetime.strptime(et, "%Y-%m-%d-%H%M%S") d2 =(datetime.strftime(d, "%d/%m/%Y %I:%M:%S %p")) print(f" PM --> {d2}")