timestamp
– Tools for representing MongoDB internal Timestamps¶
Tools for representing MongoDB internal Timestamps.
- class bson.timestamp.Timestamp(time: Union[datetime.datetime, int], inc: int)¶
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 is not an instance of :class: int ordatetime
, or inc is not an instance ofint
. RaisesValueError
if time or inc is not in [0, 2**32).- Parameters
- as_datetime() datetime.datetime ¶
Return a
datetime
instance corresponding to the time portion of thisTimestamp
.The returned datetime’s timezone is UTC.