Skip to content

Instantly share code, notes, and snippets.

@killercup
Created March 4, 2014 16:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killercup/9349548 to your computer and use it in GitHub Desktop.
Save killercup/9349548 to your computer and use it in GitHub Desktop.
Mongodb ObjectId Filter for Angular
angular.module('rm.MongoDB', [])
/**
* @method Object ID to Date
* @param {String} objectID The Object ID as String
* @return {Date} Creation Date of ObjectId
*/
.filter("objectIDtoDate", function () {
return function (objectID) {
return new Date(parseInt((""+objectID).substr(0,8), 16)*1000);
};
})
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment