Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1173

Datetime precision seems to be lost

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      pymongo==3.2.1

      Description

       
      >>> from pymongo import MongoClient
      >>> client = MongoClient('mongodb://****:*****@localhost:27017/')
      >>> db = client.test_database
      >>> import datetime
      >>> print datetime.datetime.utcnow()
       
      2016-10-21 14:42:16.964096
       
      >>> test = {"date": datetime.datetime.utcnow()}
      >>> print test
       
      {'date': datetime.datetime(2016, 10, 21, 14, 42, 23, 39207)}
       
      >>> db.tests.insert_one(test)
       
      <pymongo.results.InsertOneResult object at 0x7f4f7f9ee780>
       
      >>> print test
       
      {'date': datetime.datetime(2016, 10, 21, 14, 42, 23, 39207), '_id': ObjectId('580a2963f79060731570bdd4')}
       
      >>> print db.tests.find_one({"_id": test['_id']})
       
      {u'date': datetime.datetime(2016, 10, 21, 14, 42, 23, 39000), u'_id': ObjectId('580a2963f79060731570bdd4')}
      
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jimkennedy Jim Kennedy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: