Created
October 26, 2015 09:00
-
-
Save ronfe/18a8f67be6120100a54a to your computer and use it in GitHub Desktop.
objIdtotimestamp.js
This file contains hidden or 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
var objectIdFromDate = function (date) { | |
return Math.floor(date.getTime() / 1000).toString(16) + "0000000000000000"; | |
}; | |
var dateFromObjectId = function (objectId) { | |
return new Date(parseInt(objectId.substring(0, 8), 16) * 1000); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment