Skip to content
zenui/react-hooks

useTimeAgo

Format a date as relative time, such as "3 minutes ago" or "in 2 days", and keep it up to date. It uses Intl.RelativeTimeFormat and schedules each update for the moment the text changes. The text depends on the current time, so a server render can differ from the client; add suppressHydrationWarning to the element or render it on the client only.

Level
Basic
Since
v2.1.0
import {useTimeAgo} from '@zenuilabs/react-hooks';
Loading demo_

More in Time & Motion