How to parse datetime format in python

If you have a datetime as a string you can transform it into a datetime object using the strptime method from datetime module in python.

Strptime receive to string parameters: date interpretation and date format:

#!/usr/bin/env python

from datetime import datetime

given_date = '11/23/2018 14:20:24'

date_object = datetime.strptime(given_date, '%m/%d/%Y %H:%M:%S')

If you want to change the date format on display, you'll have to use strftime (note f instead of p in the middle of the word)

shown_date = date_object.strftime('%Y-%M-%D %H:%M:%S')