Docs
useClock

Display the current time and update it every second.

Loading...

Installation

pnpm dlx shadcn@latest add https://usekit.kiron.dev/k/use-clock

Usage

"use client"
 
import { useClock } from "@/hooks/use-clock"
 
export function Component() {
  const time = useClock({
    locale: "en-US",
    formatOptions: {
      hour: "2-digit",
      minute: "2-digit",
      second: "2-digit",
      hour12: true,
    },
  })
 
  return (
    <div>
      <p>Current time: {time}</p>
    </div>
  )
}

API Reference

Return Values

NameTypeDescription
timestringThe current time formatted as HH:mm:ss.