Skip to content

Instantly share code, notes, and snippets.

@vishalsodani vishalsodani/date_py_mongo
Last active Dec 25, 2015

What would you like to do?
Handling date in Python for Mongodb
from datetime import datetime, time
# getting date from form
dt = datetime.strptime(request.form['date'], '%Y-%m-%d')
# adding date for a record
record = {}
# need to add time (0,0)
record['date'] = datetime.combine(dt, time())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.