New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decode "timestamp" from oplog.timestamp #324
Comments
In
How is it relate to the timestamp format in
If so, is there a way to convert this format back to a human readable date in mongo shell? |
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:
|
Please note that the BSON Timestamp type is seconds since the Unix epoch plus an increment to represent multiple operations within the same second. See this for more information: http://docs.mongodb.org/master/reference/bson-types/#timestamps |
Thanks@ behackett followed the same steps but I get current time stamp no matter what value you I use rs0:SECONDARY> new ISODate(new Timestamp(1442244777, 386) * 1000) |
@upenblog Please follow updated step. Go to python and use datetime. |
troubleshooting notes, if you get:
|
Extra credit: if you need to convert from E.g. |
It failed when I imported the util module. How do I resolve the problem like this? All right, I know what question is. I need to install the pymongo module. |
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
|
On the wiki it says:
The exact format of this file depends on MongoDB's toplogy. For a single replica set, the format is:
An example would be:
What format is this timestamp in, and how do you convert say,
6185588281674039941
, to a normal date?Thanks.
The text was updated successfully, but these errors were encountered: