Skip to content

Instantly share code, notes, and snippets.

@eperedo
Created October 17, 2015 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eperedo/646c702119100949cf38 to your computer and use it in GitHub Desktop.
Save eperedo/646c702119100949cf38 to your computer and use it in GitHub Desktop.
Age
angular
.module('common')
.filter('age', ageFilter);
function ageFilter () {
return function (input, params) {
if (input) {
var date = new Date(input);
var ageDifMs = Date.now() - date.getTime();
var ageDate = new Date(ageDifMs);
return Math.abs(ageDate.getUTCFullYear() - 1970);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment