Created
October 17, 2015 18:03
-
-
Save eperedo/646c702119100949cf38 to your computer and use it in GitHub Desktop.
Age
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
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