Skip to content

Instantly share code, notes, and snippets.

@vishalsodani
Last active December 25, 2015 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vishalsodani/6895437 to your computer and use it in GitHub Desktop.
Save vishalsodani/6895437 to your computer and use it in GitHub Desktop.
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