---
title: "Time Ago"
description: "When something happened, in words such as 5 minutes ago, or as a running time. The text stays true while the page is open."
url: https://gelatinui.com/components/time-ago
markdown_url: https://gelatinui.com/components/time-ago.md
access: free
install: "npx shadcn@latest add @gelatin-ui/time-ago"
registry_item: https://gelatinui.com/r/time-ago.json
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Time Ago

> When something happened, in words such as 5 minutes ago, or as a running time. The text stays true while the page is open.

Page: https://gelatinui.com/components/time-ago

## When to use it

Best for: When something happened, in words that stay true while the page is open.

- Use `length="short"` in table cells.
- Use `absoluteAfter="7d"` to show a date after a limit.
- Use `kind="elapsed"` for the time since a start.

## When not to use it

- To pick a date, use a [Date Picker](https://gelatinui.com/components/date-picker.md).

## Notes for agents

- `date` takes a `Date`, ISO text, epoch ms, or a `DateValue`.
- A bad or missing date shows a dash, with no timer. `TimeAgoEmpty` sets your own text.
- Pass `locale` in a server-rendered app, so the words match.
- Each instance sets one timer, to the moment its text changes.
- `now` fixes the time for tests, and the text then never updates.

## Anatomy

```text
TimeAgo
└─ TimeAgoEmpty (0..n)
```

## API reference

### TimeAgo

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `date` | `DateLike \| null` |  | The moment: a `Date`, an ISO string, epoch milliseconds, or a `DateValue` (`#/lib/date-parse`). Past and future both work. `null`, `undefined`, and a value that is not a date show the empty text. |
| `kind` | `"elapsed" \| "relative"` | "relative" | `relative` (default): "5 minutes ago". `elapsed`: the time since `date`, "1m 25s". |
| `length` | `RelativeTimeFormatStyle` |  | The length of the words, the `style` option of `Intl.RelativeTimeFormat` and `Intl.DurationFormat`: `long` "5 minutes ago", `short` "5 min. ago", `narrow` "5m ago". Default: `long` for `relative`, `narrow` for `elapsed`. The prop is not named `style`: React and the lint read `style` as the CSS inline style, which a component does not take. |
| `numeric` | `RelativeTimeFormatNumeric` | "auto" | `auto` (default): "now", "yesterday", "tomorrow" (by local calendar day), and "last week", "next month", "last year". `always`: "0 seconds ago", "1 day ago", "1 week ago". |
| `absoluteAfter` | `union` |  | From this distance on, show the date in place of the words: "Oct 3", and "Oct 3, 2025" in another year. Milliseconds, or a count and a unit (`"45s"`, `"30m"`, `"12h"`, `"7d"`, `"2w"`). Default: never. |
| `locale` | `string` |  | The BCP 47 language tag ("en-US", "ar"). Default: the `DisplayLocaleProvider`, else "en-US". |
| `timeZone` | `string` |  | The IANA zone of the absolute date and the tooltip date. Default: the reader's zone. |
| `now` | `number \| Date` |  | A fixed now for tests and stories. With it, the text never updates. |
| `tooltip` | `boolean` | true | Show the full date in a Tooltip on hover. Default `true`. |
| `dateFormat` | `DateTimeFormatOptions` | FULL_DATE_FORMAT | `Intl.DateTimeFormat` options of the tooltip date. Default `{ dateStyle: "long", timeStyle: "short" }`. |
| `children` | `ReactNode` |  | A `TimeAgoEmpty` part: the words of no value. With a value, they are not drawn. |

### TimeAgoEmpty

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `data-slot` | `string` |  | The `data-slot` of the root: the item's own slot (`"time-ago"`). Default `"empty-value"`. |

Also takes every prop of Base UI `UseRender`: https://base-ui.com/react/components/use-render

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| TimeAgo | `time-ago` |  |  |  |
| TimeAgoEmpty | `time-ago-empty` |  |  |  |

## Usage

Pass the moment. Put a `TimeAgoEmpty` inside for a document that nobody opened yet.

```tsx title="recent-documents.tsx"
import { TimeAgo, TimeAgoEmpty } from "@/components/ui/time-ago";

const DOCUMENTS: { name: string; openedAt: string | null }[] = [
  { name: "Roadmap 2027", openedAt: "2026-11-12T08:40:00Z" },
  { name: "Hiring plan", openedAt: "2026-11-09T16:05:00Z" },
  { name: "Brand guide", openedAt: null },
];

export function RecentDocuments() {
  return (
    <ul className="flex w-64 flex-col gap-1 text-sm">
      {DOCUMENTS.map((document) => {
        return (
          <li key={document.name} className="flex justify-between gap-4">
            {document.name}
            <TimeAgo date={document.openedAt} className="text-muted-foreground">
              <TimeAgoEmpty>Never opened</TimeAgoEmpty>
            </TimeAgo>
          </li>
        );
      })}
    </ul>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/time-ago
```

It adds 34 registry items: 31 files, 5106 lines, and the npm packages `@base-ui/react`, `@internationalized/date`, `clsx`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Full Value](https://gelatinui.com/components/full-value.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Full Value](https://gelatinui.com/components/full-value.md)
- [Tooltip](https://gelatinui.com/components/tooltip.md)

## Accessibility

It renders `<time dateTime>` with the ISO date.

It is text, with no tab stop. The keyboard and touch do not open its Tooltip.

## Motion

| Part | Motion |
| --- | --- |
| Text | none · the words change at once, with no fade |
| Tooltip | popup · the full date opens on hover |
