Skip to content

Instantly share code, notes, and snippets.

@Mdslino
Created March 17, 2019 13:18
Show Gist options
  • Save Mdslino/e787905076a504ca1d647e0d3ebabb6e to your computer and use it in GitHub Desktop.
Save Mdslino/e787905076a504ca1d647e0d3ebabb6e to your computer and use it in GitHub Desktop.
Datetime convert from string
from datetime import datetime
datetime_obj1 = datetime.strptime('2006-01-02T15:04:05', '%Y-%m-%dT%H:%M:%S')
datetime_obj2 = datetime.strptime('2006-01-02 15:04:05', '%Y-%m-%d %H:%M:%S')
datetime_obj3 = datetime.strptime('02/01/2016 15:04:05', '%d/%m/%Y %H:%M:%S')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment