Aug-16-2018, 09:42 AM
Hi All,
I am getting time as in this format '20180801194918.0', I want convert this to date time format.
below in the my code, but need suggestion
I am getting time as in this format '20180801194918.0', I want convert this to date time format.
below in the my code, but need suggestion
a = "20180801194918.0"
year = a[:4]
month = a[4:][:2]
date = a[6:][:2]
hours = a[8:][:2]
mins = a[10:][:2]
seconds = a[12:][:2]
datetimes = year+"-"+month+"-"+date+" "+hours+":"+mins+":"+seconds
print(datetimes)Output:2018-08-01 19:49:18
