Write a Python program to convert string into a datetime object


Topic: Write a Python program to convert string into a datetime object

Solution

from datetime import datetime
date_string = "Mar 26 2021  4:20PM"
datetime_object = datetime.strptime(date_string, '%b %d %Y %I:%M%p')
print(datetime_object)



List all Python Programs