New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

time-ago-pipe

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

time-ago-pipe

A simple Angular 2 pipe to change a date into a string of how long ago from it is from now

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.5K
decreased by-16.14%
Maintainers
1
Weekly downloads
 
Created
Source

time-ago-pipe

Build Status npm npm GitHub issues npm

A really simple, lightweight Angular 2 pipe to convert a date/time into a string saying how long ago from now it was.

Time RangeOutput
0 - 45 secondsa few seconds ago
45 - 90 secondsa minute ago
90 seconds - 45 minutesX minutes ago
45 - 90 minutesan hour ago
90 minutes - 22 hoursX hours ago
22 - 36 hoursa day ago
36 hours - 25 daysX days ago
25 - 45 daysa month ago
45 - 345 daysX months ago
345 - 545 days (1.5 years)a year ago
546 days+X years ago
##Installation
npm install time-ago-pipe --save

Usage

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:

SystemJS

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]
})

Keywords

FAQs

Package last updated on 25 Sep 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc