# General Translation Changelog: gt-next 6.15.0: `<RelativeTime>` in tutti i pacchetti React
URL: https://generaltranslation.com/it/blog/gt-next_v6_15_0.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 
Authors: Archie McKenzie
Published: 2026-04-01

## Panoramica

Un nuovo componente [`<RelativeTime>`](/docs/react/reference/components/relative-time) è ora disponibile in tutti i pacchetti React di GT. Esegue il rendering di stringhe localizzate di tempo relativo come &quot;2 ore fa&quot; o &quot;tra 3 giorni&quot; utilizzando l&#39;API `Intl.RelativeTimeFormat` integrata del browser.

| Pacchetto            | Versione | Export                                                                                                                             |
| -------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `gt-next`            | 6.15.0   | [`<RelativeTime>`](/docs/react/reference/components/relative-time) (client + server)                                               |
| `gt-react`           | 10.16.0  | [`<RelativeTime>`](/docs/react/reference/components/relative-time) (client)                                                        |
| `gt-tanstack-start`  | 0.3.0    | [`<RelativeTime>`](/docs/react/reference/components/relative-time) (client)                                                        |
| `generaltranslation` | 8.2.0    | [`formatRelativeTimeFromDate()`](/docs/platform/core/reference/utility-functions/formatting/format-relative-time-from-date) (core) |
| `gt` (CLI)           | 2.14.0   | rilevamento del componente [`RelativeTime`](/docs/react/reference/components/relative-time)                                        |

## Utilizzo

### Selezione automatica dell&#39;unità da una Date

Passa una `Date` e il componente selezionerà automaticamente l&#39;unità più adatta (secondi, minuti, ore, giorni, settimane, mesi o anni).

```tsx
import { RelativeTime } from 'gt-next';

export default function PostTimestamp({ post }) {
  return <RelativeTime>{post.createdAt}</RelativeTime>;
  // "2 ore fa", "3 giorni fa", "tra 5 minuti", ecc.
}
```


### Valore e unità espliciti

Specifica un valore e un&#39;unità esatti, in linea con `Intl.RelativeTimeFormat`.

```tsx
import { RelativeTime } from 'gt-next';

export default function Reminder() {
  return (
    <p>
      Your trial ends <RelativeTime value={3} unit="day" />.
    </p>
  );
  // "Il tuo periodo di prova termina tra 3 giorni."
}
```


### Nel contenuto tradotto

Racchiudi [`<RelativeTime>`](/docs/react/reference/components/relative-time) in un componente [`<T>`](/docs/react/reference/components/t) per includerlo nelle frasi tradotte.

```tsx
import { T, RelativeTime } from 'gt-next';

export default function Comment({ comment }) {
  return (
    <T id="commentPosted">
      Posted <RelativeTime>{comment.createdAt}</RelativeTime>
    </T>
  );
}
```

### Funzione principale

Per i contesti non basati su componenti, usa la funzione autonoma:

```ts
import { formatRelativeTimeFromDate } from 'generaltranslation';

const label = formatRelativeTimeFromDate(someDate, {
  locales: ['en-US'],
  baseDate: new Date(),
});
// "2 ore fa"
```


## Affidabilità dell&#39;idratazione

[`<RelativeTime>`](/docs/react/reference/components/relative-time) calcola il tempo relativo localmente, il che può causare errori di idratazione nelle app con rendering eseguito sul server. Fissa `baseDate` e `locales` per mantenere server e client sincronizzati:

```tsx
const now = new Date();

<RelativeTime baseDate={now} locales={['en-US']}>
  {post.createdAt}
</RelativeTime>
```

## Collegamenti

* [PR #1153 — feat: aggiunta del componente `<RelativeTime>`](https://github.com/generaltranslation/gt/pull/1153)
* [`<RelativeTime>` docs](/docs/react/reference/components/relative-time)

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
