Decode "timestamp" from oplog.timestamp
See original GitHub issueOn the wiki it says: The exact format of this file depends on MongoDB’s toplogy. For a single replica set, the format is:
["oplog name", timestamp]
An example would be:
["Collection(Database(MongoClient('localhost', 27017), u'local'), u'oplog.rs')", 6185588281674039941]
What format is this timestamp in, and how do you convert say, 6185588281674039941
, to a normal date?
Thanks.
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
how to Convert Oplog Timestamp into ISO Date-time
When i fetched the timestamp of operation i got is as ". ts" : Timestamp(1412767541, 1). How can i convert into ISO date-time...
Read more >MongoDB : Convert Oplog timestamp into ISO date
Most easy way to figure out the recent changes (any DB any collection) in mongo Database is to query to Oplog with sorting...
Read more >Mongo 3.4 oplog timestamp to epoch - Stack Overflow
I am trying to convert oplog ts field to unix epoch time. oplog document { "ts" : Timestamp(6454921106666029, 1), "t" : NumberLong(2), ...
Read more >[MONGOSH-1029] Cannot use timestamp from oplog for filtering
I'm trying to prepare a query that will use the `clusterTime` for this operation but with no luck. The clusterTime is a BSON...
Read more >Tools for representing MongoDB internal Timestamps
Tools for representing MongoDB internal Timestamps. ... Create a new Timestamp . This class is only for use with the MongoDB opLog. If...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay, found a solution for this.
util.py has a method long_to_bson_ts, use Python to run the method directly:
For example:
And you will get a Timestamp object back.
In python, use datetime to convert Timestamp to human readable form:
It will return:
For comparison purpose, this command will return current system time:
Update, I’ve tried the following on my mac terminal and no dependencies issue. Convert from Epoch time to bson format (oplog) and vice versa.
https://atharva-inamdar.medium.com/understanding-mongodb-oplog-249f3996f528
pip install pymongo
python3