Huge News!Announcing our $40M Series B led by Abstract Ventures.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 really simple, lightweight Angular pipe for converting a date string into a time ago

  • 1.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.6K
increased by26.58%
Maintainers
1
Weekly downloads
 
Created
Source

time-ago-pipe

Build Status npm npm GitHub issues npm

A really simple, lightweight Angular pipe for converting a date string into a time ago

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

It can be imported into your angular project, as you would for any other library.

In the @NgModule you want to use it in

import {TimeAgoPipe} from 'time-ago-pipe';

add "TimeAgoPipe" to your declarations

@NgModule({
	imports: [... etc ...],
	declarations: [..., TimeAgoPipe, ... ]
})

In your component templates you can just do:

<span>{{your_date | timeAgo}}</span>

where "your_date" is a local date string, which could be parsed by the standard Js Date()

If this value is null or not parsable as a date, then the pipe will display nothing

Keywords

FAQs

Package last updated on 26 Feb 2018

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