I have three unique date formats, listed below
date1 = "2018-05-31 14:34:42+00:00"
date2 = "2018-05-21T14:49:52.833"
date3 = "2018-06-01 00:00:00"
How can I convert into single date format("%Y-%m-%d %H:%M:%S"
) of all these three dates using python?
Tried the below code but I'm getting ValueError
and TypeError
's
from dateutil.parser import parse
def parse_date(request_date):
request_date = parse(request_date)
parsed_date = request_date.strftime("%Y-%m-%d %H:%M:%S")
return parsed_date