# Timestamp hover card with active relative time

> Timestamp hover card with active relative time

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

- Page, with a live preview: https://shadcn.exchange/r/reui/c-hover-card-7
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/reui/c-hover-card-7-light-d8538c007291ac82.png
- Registry item: https://reui.io/r/new-york-v4/c-hover-card-7.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-hover-card-7.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`, `hover-card`, `separator`

## Files

### `c-hover-card-7.tsx`

```tsx
"use client"

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

import {
  HoverCard,
  HoverCardContent,
  HoverCardTrigger,
} from "@/components/ui/hover-card"
import { Separator } from "@/components/ui/separator"

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{" "}
        <HoverCard>
          <HoverCardTrigger
            delay={100}
            closeDelay={100}
            className="text-foreground cursor-default underline decoration-dashed decoration-1 underline-offset-4"
          >
            {formatDistanceToNow(referenceTime, { addSuffix: true })}
          </HoverCardTrigger>
          <HoverCardContent className="w-78 p-0">
            <p className="text-foreground px-2 py-1 font-medium">
              {formatDistanceToNow(referenceTime, { addSuffix: true })}
            </p>
            <Separator />
            <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>
          </HoverCardContent>
        </HoverCard>{" "}
        by CI/CD pipeline.
      </p>
    </div>
  )
}
```
