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

NameTypeDescriptionDefault ValueOptional
dateDateThe date to format into a 'time ago' string.-No

Return Values

NameTypeDescription
timeAgostringThe formatted time ago string.