1
2from datetime import datetime
3
4date_string = "21 June, 2018"
5
6print("date_string =", date_string)
7print("type of date_string =", type(date_string))
8
9date_object = datetime.strptime(date_string, "%d %B, %Y")
10
11print("date_object =", date_object)
12print("type of date_object =", type(date_object))
13
1
2date_string = 21 June, 2018
3type of date_string = <class 'str'>
4date_object = 2018-06-21 00:00:00
5type of date_object = <class 'datetime.datetime'>
6