I want this string "20180425.142117" to convert to human readable format. E.g. 25th April 2018, 2:21 pm in Python
Any ideas how to do this?
I want this string "20180425.142117" to convert to human readable format. E.g. 25th April 2018, 2:21 pm in Python
Any ideas how to do this?
Try using the datetime library.
import datetime as dt
time_str = "20180425.142117"
# Convert to a datetime
time_dt = dt.datetime.strptime(time_str, '%Y%m%d.%H%M%S')
# Convert back to string with the right format
human_time = dt.datetime.strftime(time_dt, '%dth %b %Y, %I:%M%p')
print(human_time)
I have to say that I look up the codes each time I need to do something custom.