npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@apurvapawaskar/timeago-plus

v0.1.6

Published

Tiny, dependency-free relative time strings (just now, 2m ago, in 3h).

Readme

@apurvapawaskar/timeago-plus

npm bundle size downloads license TypeScript ready

Tiny, dependency-free relative time formatter with i18n, React hooks & Angular pipes.

  • No runtime dependencies
  • ESM + CommonJS support
  • Tree-shakeable (sideEffects: false)
  • Extremely small footprint

📦 Install

npm i @apurvapawaskar/timeago-plus

⚡ Basic Usage

  • Input: Date | number | string — invalid inputs never throw, return "invalid date"
  • Numbers < 1e12 are treated as epoch seconds; >= 1e12 as epoch milliseconds
import { timeAgo } from "@apurvapawaskar/timeago-plus";

timeAgo(new Date(Date.now() - 30_000)); // "30s ago"
timeAgo(Date.now() - 2 * 60_000);      // "2m ago"
timeAgo(new Date(Date.now() + 2 * 60_000)); // "in 2m"
timeAgo(Date.now() - 1_000);           // "just now" (within 2s threshold)

⚙️ Options

timeAgo(input, {
  now?: Date | number,       // reference time, defaults to Date.now()
  short?: boolean,           // true = "2m ago", false = "2 minutes ago". Default: true
  future?: boolean,          // allow future output like "in 2m". Default: true
  locale?: string,           // "en" | "fr" | "es" (or subtag like "es-ES"). Default: "en"
  labels?: Partial<TimeAgoLabels>, // override any label string
  justNowThreshold?: number, // seconds within which to return "just now". Minimum 2, default: 2
  futureDisabledLabel?: string, // string to show when future: false and input is a future date. Default: "just now"
});

Behaviour notes:

  • Seconds use Math.floor; all larger units use Math.round

⚛ React

Requires React 17–19. react is a peer dependency (not bundled).

import { useTimeAgo } from "@apurvapawaskar/timeago-plus/react";

export function Example() {
  const text = useTimeAgo(Date.now() - 30_000);
  return <span>{text}</span>;
}

For optimal performance, memoize the options object with useMemo when passing dynamic options.

🅰 Angular

Requires Angular 14+. TimeAgoPipe is a standalone pipe — add it to imports, not declarations.

import { TimeAgoPipe } from "@apurvapawaskar/timeago-plus/angular";

@Component({
  standalone: true,
  imports: [TimeAgoPipe],
  template: `<span>{{ createdAt | timeAgo }}</span>`
})
export class ExampleComponent {}

With options:

<span>{{ createdAt | timeAgo : { locale: 'fr', short: false } }}</span>

Using from an NgModule (Angular 14+):

import { NgModule } from "@angular/core";
import { TimeAgoPipe } from "@apurvapawaskar/timeago-plus/angular";

@NgModule({
  imports: [TimeAgoPipe],   // standalone pipes go in imports[], not declarations[]
  exports: [TimeAgoPipe]
})
export class SharedModule {}

🧪 Playground

Try the playground online:

📚 Docs

🛠 Development

npm test
npm run build