I want to convert type of string date to other format which as dd-mm-yyyy
date_stringg='24. Juli 2020'
date_object = datetime.strptime((date_stringg), "%d. %B %Y")
print("date_object: ", date_object)
You may need to set the locale. Juli
is not a valid month name in english language, I'm assuming it is Dutch.
Assuming you want to use the Dutch locale with datetime, you can do the following
import locale
locale.setlocale(locale.LC_TIME, "nl_nl")
After that, it will recognize Juli
so this will work
>>> date_stringg='24. Juli 2020'
>>>
>>> date_object = datetime.strptime((date_stringg), "%d. %B %Y")
>>> date_object
datetime.datetime(2020, 7, 24, 0, 0)