tiny-human-delta
v1.0.0
Published
A tiny library for calculating the difference between two human-readable dates.
Readme
tiny-human-delta
A tiny utility that converts dates into human-readable relative time strings like "3 days ago" or "in 2 months".
No dependencies. Uses Intl.RelativeTimeFormat.
Installation
npm install tiny-human-deltaUsage
CommonJS
const humanDelta = require("tiny-human-delta");
console.log(humanDelta("2026-05-29"));ES Modules
import humanDelta from "tiny-human-delta";
console.log(humanDelta("2026-05-29"));API
humanDelta(date, base?)
date (string | Date): Target date
base (Date, optional): Reference date (default: now)Returns a string like:
"3 days ago"
"in 2 months"
"5 minutes ago"Example
humanDelta("2026-06-10");
// "in 9 days"
humanDelta("2026-05-20");
// "11 days ago"