GithubHelp home page GithubHelp logo

shrikantbhalerao / time-ago-pipe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrewpoyntz/time-ago-pipe

0.0 0.0 0.0 49 KB

An Angular pipe for converting a date string into a time ago

License: MIT License

TypeScript 100.00%

time-ago-pipe's Introduction

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 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

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

time-ago-pipe's People

Contributors

andrewpoyntz avatar dfederm avatar arknotts avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.