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 🙏

© 2025 – Pkg Stats / Ryan Hefner

cc-time-ago

v3.0.2

Published

A lightweight time-ago formatter with i18n support, future dates, and real-time updates

Downloads

244

Readme

TinnovAce Time Module

npm version GitHub TypeScript

A lightweight time formatter with i18n support, future dates, real-time updates, and TypeScript types. Formats dates as "just now", "1h ago", or "in 5 minutes".

Features

  • 14 Built-in Languages + Custom Language Support
  • Future Date Formatting ("in 5 minutes")
  • Real-Time Auto Updates (Perfect for UIs)
  • Customizable Thresholds (Control when units change)
  • TypeScript Ready with Full Type Definitions
  • Compact Mode ("1h" instead of "1 hour ago")
  • Smart Caching for High Performance

Installation

npm install cc-time-ago

Basic Usage

const { timeAgo } = require('cc-time-ago');

// Basic usage
console.log(timeAgo(Date.now() - 300000)); // "5 minutes ago"

// With options
console.log(timeAgo(Date.now() + 3600000, { 
  language: 'es',
  allowFuture: true
})); // "en 1 hora"

Advanced Usage

Custom Thresholds

timeAgo(date, {
  thresholds: {
    seconds: 120,  // Show seconds up to 2 minutes
    minutes: 3600  // Show minutes up to 1 hour
  }
});

Real-Time Updates (React/Vue/etc)

const { autoUpdate } = require('cc-time-ago');

const { stop } = autoUpdate(someDate, (formattedTime) => {
  console.log(formattedTime); // Updates every 30s
});

// Call stop() when done

Add Custom Languages

const { addLanguage } = require('cc-time-ago');

addLanguage('ko', {
  justNow: '방금',
  minuteAgo: '1분 전',
  // ...
});

Options

  • language (string, default: Auto-detected)

    • Language code (e.g., 'es', 'fr')
  • compact (boolean, default: false)

    • Compact format ("1h" vs "1 hour ago")
  • allowFuture (boolean, default: false)

    • Format future dates ("in 5 minutes")
  • thresholds (object, default: See below)

    • Custom unit thresholds

Default Thresholds

{
  seconds: 60,     // Show seconds until 1 minute
  minutes: 3600,   // Show minutes until 1 hour
  hours: 86400,    // Show hours until 1 day
  days: 604800,    // Show days until 1 week
  weeks: 2600640,  // Show weeks until ~1 month
  months: 31207680 // Show months until 1 year
}

Supported Languages

  • en - English
  • es - Spanish
  • fr - French
  • de - German
  • it - Italian
  • ar - Arabic
  • tr - Turkish
  • nl - Dutch
  • ja - Japanese
  • zh - Chinese
  • ru - Russian
  • pt - Portuguese
  • hi - Hindi

Missing a language?  

Add it yourself or request it!

Contributing

1. Fork the repository

2. Add/Update languages in languages.js

3. Write tests for new features

4. Submit a PR

License

This project is licensed under the MIT License - see the LICENSE file for details.

Time Module © 2022 - 2025, a product of TinnovAce.