# Local Clock

> Timezone-aware local time chip.

A shadcn/ui block from the [@atroui](https://www.atroui.com) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/atroui/local-clock).

- Page, with a live preview: https://shadcn.exchange/r/atroui/local-clock
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/atroui/local-clock-light-9c9b2c2b76b2a048.png
- Registry item: https://www.atroui.com/r/local-clock.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://www.atroui.com/r/local-clock.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@atroui/utils`

## Files

### `registry/default/blocks/local-clock.tsx`

```tsx
"use client"

import * as React from "react"

import { cn } from "@/lib/utils"

/** Defaults — edit timezone props after install. */
const CONTENT = {
  timezone: "America/New_York",
  timezoneLabel: "ET",
}

export function LocalClock({
  timezone = CONTENT.timezone,
  timezoneLabel = CONTENT.timezoneLabel,
  className,
}: {
  timezone?: string
  timezoneLabel?: string
  className?: string
} = {}) {
  const [now, setNow] = React.useState<Date | null>(null)

  React.useEffect(() => {
    const tick = () => setNow(new Date())
    tick()
    const timer = window.setInterval(tick, 30_000)
    return () => window.clearInterval(timer)
  }, [])

  const time = now
    ? new Intl.DateTimeFormat("en-US", {
        timeZone: timezone,
        hour: "numeric",
        minute: "2-digit",
        hour12: true,
      }).format(now)
    : "—:—"

  return (
    <span
      className={cn(
        "inline-flex items-center gap-1 font-mono text-[11.5px] text-muted-foreground tabular-nums",
        className
      )}
      aria-label={`Local time in ${timezoneLabel}: ${time}`}
      title={`${timezoneLabel} · ${timezone}`}
    >
      <span className="text-foreground">{time}</span>
      <span className="text-muted-foreground/70">{timezoneLabel}</span>
    </span>
  )
}
```
