Created
February 7, 2014 01:03
-
-
Save daryltucker/8855707 to your computer and use it in GitHub Desktop.
Convert ObjectId into Epoch
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 | |
import calendar | |
import time | |
def objectid_to_epoch(_id) | |
epoch = datetime.datetime.fromtimestamp(int(str(_id)[0:8], 16)) | |
return calendar.timegm(datetime.datetime(epoch.year, epoch.month, epoch.day, epoch.hour, epoch.minute).utctimetuple()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment