I am trying to create a \'time ago\' pipe for my Angular 2 application.
It should transform a date to a string such as \'5 minutes ago\' or \'60 seconds ago\'. It wo
The following library does equivalent job in English and could be forked to change the language or support different ones:
https://www.npmjs.com/package/time-ago-pipe
npm install time-ago-pipe --save
Then in the @NgModule you want to use it in:
import {TimeAgoPipe} from 'time-ago-pipe'
@NgModule({
imports: [... etc ...],
declarations: [AppComponent, ...etc..., TimeAgoPipe],
bootstrap: [AppComponent]
})
And in the template:
{{your_date | timeAgo}}