Skip to content

Chronify is a Node.js utility that provides human-readable relative time differences between a given date and the current time. It helps you easily calculate and display how much time has passed or remains until a specified date, making it ideal for applications that need to show time-based information in a user-friendly format.

License

Notifications You must be signed in to change notification settings

sajidurdev/Chronify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

∆ Chronify

NPM Version Repository Size License Downloads Support

Chronify is a Node.js package that provides a simple way to calculate and display human-readable time differences between dates. Perfect for applications that need to show elapsed or remaining time in a user-friendly format.

Features

  • Flexible Time Units: Shows time differences in years, months, days, hours, and minutes.
  • Customizable Output: Supports both full and abbreviated unit formats.
  • Human-readable Format: Easy-to-understand phrases like "2 weeks ago" or "in 3 days."

Installation

Install Chronify via npm:

npm install chronify

Usage

Import and use Chronify in your Node.js project:

const { chronify } = require("chronify");

Example

Display the time difference from the current date:

console.log(chronify("2024-09-01T12:00:00Z"));
// Example Output: "2 weeks ago" (depending on the current date)

Customizing Output

Control the number of units displayed and use abbreviated formats:

console.log(chronify("2024-09-01T12:00:00Z", { maxUnits: 1, short: true }));
// Example Output: "2w ago" (depending on the current date)

Options

  • maxUnits (number): Maximum number of time units to display. Defaults to 2.
  • short (boolean): Use abbreviated units if true. Defaults to false.

About

Chronify is a Node.js utility that provides human-readable relative time differences between a given date and the current time. It helps you easily calculate and display how much time has passed or remains until a specified date, making it ideal for applications that need to show time-based information in a user-friendly format.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published