str date to datetime date code example
Example 1: convert str to datetime
import datetime
# str value "Apr 2, 2019" convert into any format.
datetime.datetime.strptime('Apr 2, 2019', '%b %d, %Y').strftime('%a, %d %b %Y')
Example 2: str to datetime time
>>> import datetime
>>> datetime.datetime.strptime('03:55', '%H:%M').time()
datetime.time(3, 55)