JSPM

time-ago-formatter

1.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • 0
    • Score
      100M100P100Q20039F
    • License MIT

    A lightweight JavaScript library to format timestamps into human-readable relative time (e.g., '5 minutes ago').

    Package Exports

    • time-ago-formatter
    • time-ago-formatter/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (time-ago-formatter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    time-ago-formatter

    A lightweight JavaScript/Node.js library to format timestamps into human-readable relative time (e.g., "5 minutes ago", "2 hours ago", "Yesterday").

    Installation

    Install via npm:

    npm install time-ago-formatter

    Or via yarn:

    yarn add time-ago-formatter

    Usage

    Import the Package

    const timeAgo = require("time-ago-formatter");

    Basic Usage

    console.log(timeAgo(Date.now() - 60000));   // "1 minute ago"
    console.log(timeAgo(Date.now() - 3600000)); // "1 hour ago"
    console.log(timeAgo(Date.now() - 86400000)); // "1 day ago"
    console.log(timeAgo("2023-12-01"));         // "2 months ago"

    API Reference

    timeAgo(input)

    Formats a timestamp into a compact, human-readable relative time string.

    Parameter Type Description
    input Date / String / Number The date or timestamp to format

    License

    This package is licensed under the MIT License.


    Contributing

    Contributions are welcome! Feel free to open an issue or submit a pull request.


    Author

    Developed by Rohit Chavan.