I have a date time string formatted as follows:
2012-12-03T02:00:00Z
I want to split the date and time up and display it as follows: 03/12/2012 02:00:00
How can I do this in python in as few a lines as possible?? (The 'T' and 'Z' will be removed)
I have a date time string formatted as follows:
2012-12-03T02:00:00Z
I want to split the date and time up and display it as follows: 03/12/2012 02:00:00
How can I do this in python in as few a lines as possible?? (The 'T' and 'Z' will be removed)
This goes through the datetime
library and will throw an exception if the input string is not correctly formatted or contains an invalid datetime information (leap years included!).
from datetime import datetime
datetime.strptime("2012-12-03T02:00:00Z", "%Y-%m-%dT%H:%M:%SZ").strftime("%d/%m/%Y %H:%M:%S")