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 🙏

© 2024 – Pkg Stats / Ryan Hefner

cc-time-ago

v2.1.0

Published

This is a simple module that calculates the time elapsed and has a good partten of displaying the time like "Just Now", "1 Second ago", "2 minutes ago", "2 hours ago" and so on.

Downloads

26

Readme

TinnovAce - Time Ago Module

npm version GitHub

This is a simple module that calculates the time elapsed by subtracting the time an entry was made from the current time. It has a good pattern of displaying the time like "just now," "1 second ago," "2 minutes ago," "2 hours ago," "1 day ago," "2 weeks ago," "1 month ago," "2 years ago," and so on.

You can also use the compact mode if you want something concise and compact. i.e "1d" instead of "1 day ago" or "1h" instead of "1 hour ago." Check the Compact Mode section for more information.

The module now supports multiple languages for time formatting. You can specify the language you want to use when formatting the time. Check the Languages Supported section for more information.

The module can be useful and integrated into various applications for time formatting, such as in blog posts, comments, user posts, social networks, or literally any app that uses time. The module is constantly being updated and is open source, easy to use, flexible, and scalable.

Installation

To use the module in your project, install it via npm:

npm install cc-time-ago

Usage

Include the module in your project using the import syntax:

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

The time-ago module has one method, which accepts the time an entry was made in milliseconds as the first argument and an optional second argument for specifying the language. We advise you to use the JavaScript time object with the method now() (e.g., Date.now()).

const entryTime = /* your entry time in milliseconds */;
const formattedTime = timeAgo(entryTime, 'es'); // Pass the language code as the second argument
console.log(formattedTime);

Compact Mode

You can also use the compact mode to get a more concise output:

const compactFormattedTime = timeAgo(entryTime, null, true);
console.log(compactFormattedTime); // Output might be "1h"

Languages Supported

The module supports the following languages for time formatting:

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

You can customize the language by passing the language code as the second argument when using the module. Otherwise it will attempt to detect the user's language automatically and if it fails English will be used as the default language.

Suggesting New Languages

We value your feedback and encourage you to suggest additional languages for time formatting. If there's a language you'd like to see supported, please open an issue in the repository, and we'll do our best to add it in future updates. Your input is essential in making this module more inclusive and versatile.

Contribution

Feel free to contribute to the module. Your pull requests will be reviewed and approved. For any problems encountered or further queries, please raise an issue.

License

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

Time Ago Module © 2022 - 2024, a product of TinnovAce.