Created
September 4, 2013 17:33
-
-
Save daryltucker/6440158 to your computer and use it in GitHub Desktop.
Creating a [decent] ObjectId for a previous time in python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from bson import ObjectId | |
pastDate = datetime.datetime(2013, 9, 4, 0, 57, 12, 35683) | |
ob = ObjectId() | |
obx = ObjectId().from_datetime(pastDate) | |
# Here it is: | |
pastId = ObjectId(str(obx)[:8] + str(ob)[8:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment