Skip to content

Instantly share code, notes, and snippets.

@dninomiya
Last active November 12, 2017 12:09
Show Gist options
  • Save dninomiya/31b5c46d94d9daaad861553cd706be74 to your computer and use it in GitHub Desktop.
Save dninomiya/31b5c46d94d9daaad861553cd706be74 to your computer and use it in GitHub Desktop.
age pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'age'
})
export class AgePipe implements PipeTransform {
transform(value: number, args?: any): any {
const ageDate = new Date(Date.now() - value);
return Math.abs(ageDate.getUTCFullYear() - 1970);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment