timestamp – Tools for representing MongoDB internal Timestamps

New in version 1.5.

Tools for representing MongoDB internal Timestamps.

class pymongo.timestamp.Timestamp(time, inc)

Create a new Timestamp.

This class is only for use with the MongoDB opLog. If you need to store a regular timestamp, please use a datetime.

Raises TypeError if time and inc are not instances of int. Raises ValueError if time or inc is not in [0, 2**32).

Parameters:
  • time: time in seconds since epoch UTC
  • inc: the incrementing counter
as_datetime()
Return a datetime instance corresponding to the time portion of this Timestamp.
inc
Get the inc portion of this Timestamp.
time
Get the time portion of this Timestamp.

Previous topic

son_manipulator – Manipulators that can edit SON documents as they are saved or retrieved

Next topic

json_util – Tools for using Python’s json module with MongoDB documents

This Page