'Convert string in format datetime

I have this date that comes to me in the following format and it is string type

from datetime import datetime 

fecha_str = "2021-09-27T20:42:34.099000Z"

fecha_datetime = datetime.strptime(fecha_str,'%d del %m de %Y a las %H:%M')

I need to transform it into a datetime type varibale so that I can manipulate it and only show the information that is needed.



Solution 1:[1]

from datetime import datetime

date_time_str = '18/09/19 01:55:19'

date_time_obj = datetime.strptime(date_time_str, '%d/%m/%y %H:%M:%S')

print ("The type of the date is now", type(date_time_obj)) print ("The date is", date_time_obj)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hansen Marcelino Azali