![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
time-ago-pipe
Advanced tools
A simple Angular 2 pipe to change a date into a string of how long ago from it is from now
A really simple, lightweight Angular 2 pipe to convert a date/time into a string saying how long ago from now it was.
Time Range | Output |
---|---|
0 - 45 seconds | a few seconds ago |
45 - 90 seconds | a minute ago |
90 seconds - 45 minutes | X minutes ago |
45 - 90 minutes | an hour ago |
90 minutes - 22 hours | X hours ago |
22 - 36 hours | a day ago |
36 hours - 25 days | X days ago |
25 - 45 days | a month ago |
45 - 345 days | X months ago |
345 - 545 days (1.5 years) | a year ago |
546 days+ | X years ago |
##Installation | |
npm install time-ago-pipe --save |
In your component templates you can just do:
<span>{{your_date | timeAgo}}</span>
where "your_date" is something, which could be parsed by the standard Js Date()
It can be imported into your angular project, as you would for any other library.
The d.ts files are included, so typings should be picked up automatically :+1:
in your system config file:
map: {
'time-ago-pipe':'node_modules/time-ago-pipe',
etc
}
packages: {
'time-ago-pipe': {main: 'time-ago-pipe.js'},
etc
}
Then in the @NgModule you want to use it in
import {TimeAgoPipe} from 'time-ago-pipe
& add "TimeAgoPipe" to your declarations
@NgModule({
imports: [... etc ...],
declarations: [AppComponent, ...etc..., TimeAgoPipe],
bootstrap: [AppComponent]
})
FAQs
A really simple, lightweight Angular pipe for converting a date string into a time ago
The npm package time-ago-pipe receives a total of 2,608 weekly downloads. As such, time-ago-pipe popularity was classified as popular.
We found that time-ago-pipe demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.