# Relative time popover with timezone details

> Relative time popover with timezone details

A shadcn/ui block from the [@reui](https://reui.io) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/reui/c-popover-9).

- Page, with a live preview: https://shadcn.exchange/r/reui/c-popover-9
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/reui/c-popover-9-light-b7e426e0aca94923.png
- Registry item: https://reui.io/r/new-york-v4/c-popover-9.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://reui.io/r/new-york-v4/c-popover-9.json
```

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

## Dependencies

- npm packages: `date-fns`
- Registry items: `@reui/badge`, `popover`

## Files

### `c-popover-9.tsx`

```tsx
"use client"

import { useEffect, useState } from "react"
import { Badge } from "@/components/reui/badge"
import { format, formatDistanceToNow } from "date-fns"

import {
  Popover,
  PopoverContent,
  PopoverTrigger,
} from "@/components/ui/popover"

export function Pattern() {
  const [now, setNow] = useState(new Date())

  useEffect(() => {
    const timer = setInterval(() => setNow(new Date()), 1000)
    return () => clearInterval(timer)
  }, [])

  // Static reference time for the "last deployed" example
  const referenceTime = new Date(now.getTime() - 1000 * 60 * 120) // 2 hours ago

  return (
    <div className="flex min-h-[100px] items-center justify-center">
      <p className="text-muted-foreground text-sm">
        Last deployed{" "}
        <Popover>
          <PopoverTrigger
            render={
              <button className="text-foreground cursor-default underline decoration-dashed decoration-1 underline-offset-4 outline-hidden" />
            }
          >
            {formatDistanceToNow(referenceTime, { addSuffix: true })}
          </PopoverTrigger>
          <PopoverContent className="w-auto max-w-86 gap-0 p-0" align="start">
            <p className="text-foreground border-b px-2 py-1 font-medium">
              {formatDistanceToNow(referenceTime, { addSuffix: true })}
            </p>
            <div className="px-2 py-1.5">
              <table>
                <tbody>
                  <tr>
                    <td className="pr-4 pb-1.5">
                      <Badge variant="outline">UTC</Badge>
                    </td>
                    <td className="pr-6 pb-1.5">
                      {format(referenceTime, "MMM d, yyyy")}
                    </td>
                    <td className="text-muted-foreground pb-1.5">
                      {format(referenceTime, "hh:mm:ss a")}
                    </td>
                  </tr>
                  <tr>
                    <td className="pr-4">
                      <span className="bg-muted rounded px-1.5 py-0.5 font-medium">
                        {Intl.DateTimeFormat()
                          .resolvedOptions()
                          .timeZone.split("/")
                          .pop()
                          ?.replace("_", " ") || "Local"}
                      </span>
                    </td>
                    <td className="pr-6">{format(now, "MMM d, yyyy")}</td>
                    <td className="text-muted-foreground w-28">
                      {format(now, "hh:mm:ss a")}
                    </td>
                  </tr>
                </tbody>
              </table>
            </div>
          </PopoverContent>
        </Popover>{" "}
        by CI/CD pipeline.
      </p>
    </div>
  )
}
```
