This Python DateTime tutorial will teach you how to use the datetime.strptime() method in Python. This method is used to create a DateTime object from the string.
Python
x
# Import the datetime module
import datetime
# Date string
date_string = "2022-12-05"
# Convert the date string to datetime
date_time = datetime.datetime.strptime(date_string, "%Y-%m-%d")
# Display the datetime
print("datetime:", str(date_time))
Output:
datetime: 2022-12-05 00:00:00