JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q39894F
  • License MIT

A tiny JavaScript utility to convert dates into human readable 'time ago' format.

Package Exports

  • time-ago-dk
  • time-ago-dk/src/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-dk) 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-dk

A tiny JavaScript utility to convert dates into human readable "time ago" format.

Features

  • Lightweight and fast
  • Supports years, months, days, hours, minutes, and seconds
  • Returns "just now" for very recent times
  • ES module compatible

Installation

npm install time-ago-dk

Usage

import { timeAgo } from "time-ago-dk";

console.log(timeAgo(new Date(Date.now() - 60000))); // "1 minute ago"
console.log(timeAgo(new Date(Date.now() - 3600000))); // "1 hour ago"
console.log(timeAgo(new Date(Date.now() - 1000))); // "just now"

API

timeAgo(inputDate)

  • Parameters:
    • inputDate (Date | string | number): The date to convert. Can be a Date object, ISO string, or timestamp.
  • Returns: string - The human-readable time ago string.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

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