Function: formatRelativeTimestamp()
formatRelativeTimestamp(
timestamp
:number
):string
Defined in: src/utils/time.ts:133
Formats timestamp in a human-readable relative format.
Parametersโ
timestampโ
number
Unix timestamp in milliseconds
Returnsโ
string
Relative time description
Remarksโ
Shows how long ago the timestamp occurred relative to the current time. Provides appropriate granularity based on the time difference: days for old events, hours and minutes for recent events, and "Just now" for very recent events.
Exampleโ
formatRelativeTimestamp(Date.now() - 120000); // "2 minutes ago"
formatRelativeTimestamp(Date.now() - 86400000); // "1 day ago"
formatRelativeTimestamp(Date.now() - 10000); // "Just now"