JSPM

uploaded-time-ago

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q25437F
  • License ISC

It calculates the time just like Facebook whenever a new post or anything is uploaded and this function is used to calculate the time distance from the current time.

Package Exports

  • uploaded-time-ago
  • uploaded-time-ago/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 (uploaded-time-ago) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

uploaded-time-ago

A simple JavaScript function to display human-readable relative time strings like "5 minutes ago", "2 days ago", etc. Perfect for showing timestamps in a user-friendly format.

Features

  • Converts timestamps to relative time strings.
  • Handles future timestamps and invalid inputs gracefully.
  • Easy to use in both browser and Node.js environments.

Installation

You can install the package using npm:

npm install uploaded-time-ago
import timeAgo from "uploaded-time-ago";

// Example usage
console.log(timeAgo(Date.now() - 45000)); // 45 seconds ago
console.log(timeAgo(Date.now() - 3600000)); // 1 hour ago
console.log(timeAgo(Date.now() - 86400000)); // 1 day ago
console.log(timeAgo(Date.now() + 45000)); // Timestamp is in the future
console.log(timeAgo()); // Invalid timestamp