title: Putting a Date object into MongoDB, getting back a float when querying with pymongo
body: <p>I'm adding a date value into a MongoDB collection as part of a map-reduce call:</p>
  
  <pre><code>day = Date.UTC(this.time.getFullYear(), this.time.getMonth(), this.time.getDate());
  emit({ user : this.user, day : day }, { count : 1 });
  </code></pre>
  
  <p>When I later query this collection in the Mongo shell I see:</p>
  
  <pre><code>{ "_id" : { "user" : "assaf", "day" : 1331769600000 }, "value" : { "count" : 15 } }
  { "_id" : { "user" : "assaf", "day" : 1331856000000 }, "value" : { "count" : 57 } }
  </code></pre>
  
  <p>Somehow the date looks like an integer - I guess it's some timestamp representation.
  If I do this:</p>
  
  <pre><code>PRIMARY&gt; new Date(db.my_collection.find()[0]["_id"]["day"])
  </code></pre>
  
  <p>I get back the correct date:</p>
  
  <pre><code>ISODate("2012-03-19T00:00:00Z")
  </code></pre>
  
  <p>My question is how to do the same in pymongo. If I run any query on the above collection, pymongo returns documents in which the <code>day</code> value as a float type with the same value as the timestamp:</p>
  
  <pre><code>dict: {u'_id': {u'user': u'ariel', u'day': 1332115200000.0}, u'value': {u'count': 99.0}}
  </code></pre>
  
  <p>How do I turn this timestamp into a Python <code>datetime</code>?</p>