I'm needing to prepare a date for insertion into MongoDB based on user input (string).
Code:
from datetime import datetime
import time
...
self.d_birthdate = time.strptime('6/8/1980', '%m/%d/%Y')
self.d_created = dict.get('d_created', datetime.now())
...
The d_created
attribute works fine, but b_birthdate
doesn't since I'm on Python 2.4, and I can't use the method discussed here. So, I had to use the code you see above. However, when I try to insert this document into MongoDB, it complains about d_birthdate
. Is there a way to convert it to a datetime object or maybe some better method? Thanks.