Skip to content

Instantly share code, notes, and snippets.

@karan9
Created November 2, 2020 16:22
Show Gist options
  • Save karan9/108595ce7e9d7602a5cc0b94f7665115 to your computer and use it in GitHub Desktop.
Save karan9/108595ce7e9d7602a5cc0b94f7665115 to your computer and use it in GitHub Desktop.
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