@tempots/ui

timeDiffToString() function

Converts a time difference in milliseconds to a human-readable relative time string.

Signature:

timeDiffToString: (diffInMillis: number) => string

Parameters

Parameter

Type

Description

diffInMillis

number

The time difference in milliseconds. Negative values indicate past times, positive values indicate future times.

Returns: string

A human-readable string representing the relative time difference: - For very recent times (< 1 minute): "just now" or "in a moment" - For other times: formatted strings like "2 minutes ago", "in 3 hours", "yesterday", etc.

Exceptions

{Error} Should never throw due to the Infinity max value in units array