JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q31473F
  • 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"
console.log(timeAgo(new Date(Date.now() - 86400000))); // "1 day ago"
console.log(timeAgo(new Date(Date.now() - 2592000000))); // "1 month ago"
console.log(timeAgo(new Date(Date.now() - 31536000000))); // "1 year ago"

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.