For a project, I'm fetching data from Salesforce and MongoDB and comparing field by field. The issue is the dates in MongoDB are stored in a string such as "Apr 15, 2016, 4:08:03 AM". The same field is stored in as DateTime datatype in Salesforce such as "2016-04-15T04:08:03.000+0000". I'm trying to convert either one of these fields to match with other format in python so I can compare them
So far, I have this
from datetime import datetime datetime_object = datetime.strptime('Jun 1 2005 1:33PM', '%b %d %Y %I:%M%p') print(str(datetime_object)) #'2005-06-01 13:33:00'
datetime.strptimealready gives you a datetime instance. What's your question?