Docs
useTimeAgo
Format a date into a human-readable 'time ago' format.
Loading...
Installation
pnpm dlx shadcn@latest add https://usekit.kiron.dev/k/use-time-ago
Usage
"use client"
import { useTimeAgo } from "@/hooks/use-time-ago"
export function Component() {
const timeAgo = useTimeAgo(new Date("2025-05-01T12:00:00Z"))
return (
<div>
<p>Time ago: {timeAgo}</p>
</div>
)
}
API Reference
Parameters
Name | Type | Description | Default Value | Optional |
---|---|---|---|---|
date | Date | The date to format into a 'time ago' string. | - | No |
Return Values
Name | Type | Description |
---|---|---|
timeAgo | string | The formatted time ago string. |