Skip to content

Instantly share code, notes, and snippets.

@ronfe
Created October 26, 2015 09:00
Show Gist options
  • Save ronfe/18a8f67be6120100a54a to your computer and use it in GitHub Desktop.
Save ronfe/18a8f67be6120100a54a to your computer and use it in GitHub Desktop.
objIdtotimestamp.js
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