JavaScript Relative Time
Generate human-readable relative timestamps
Checksum (SHA-256)0379b1e8e15a19e050dbbb863c9b01bd94dde3a1bea15ffbb8ef856a030cda89
Namekiwi.mia.0021
Version25.0.0
Stage90.92 Archived
Released2025-06-26 00:00:00
Next version25.1.0
A small (tiny) JavaScript project to generate a customizable and human-readable string to represent the relative time between two points in time.
/**
* Returns a human-readable string representing the relative time between a target and a reference date.
* @param target The target date in the future, past, or present.
* @param excludedUnits An array of time units to exclude from the output (e.g. ["year", "month"]).
* @param reference The reference date to compare against, usually the current date.
* @returns A string representing the relative time, (e.g. "2 days ago", "3 weeks from now").
* @throws Will throw an error if the target or reference date is invalid.
*/