# General Translation React SDKs (gt-react, gt-next, gt-react-native): Formatting numbers and dates URL: https://generaltranslation.com/en-US/docs/react/guides/formatting-variables.mdx --- title: Formatting numbers and dates description: How to format numbers, currency, dates, relative time, and dynamic values for each locale in React. related: links: - /docs/react/guides/handling-plurals-and-branches - /docs/react/guides/translating-jsx - /docs/react/guides/translating-strings - /docs/react/guides/managing-locales --- Different locales have different conventions for formatting variables such as numbers, dates, times, and currency. Use the matching component for values that should adapt to the active locale, and use [``](/docs/react/reference/components/var) for dynamic values that should render unchanged. ## Choose the right component [#choose] - [``](/docs/react/reference/components/var) renders a dynamic value without translating or formatting it. - [``](/docs/react/reference/components/num) formats numbers, percentages, and units for the active locale. - [``](/docs/react/reference/components/currency) formats an amount and currency code without converting its value. - [``](/docs/react/reference/components/datetime) formats an absolute date, time, or both for the active locale. - [``](/docs/react/reference/components/relative-time) formats relative wording such as "yesterday" or "in 3 days." These components share the same behavior across React, Next.js, TanStack Start, and React Native. Import them from your framework's package. ## Insert a raw value with `` [#var] Use [``](/docs/react/reference/components/var) for dynamic content that should render exactly as provided: such as a username, email address, or identifier. Inside [``](/docs/react/reference/components/t), it keeps the value out of the translation while allowing the surrounding sentence to remain translatable. ```tsx import { T, Var } from 'gt-react';

Signed in as {user.email}

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

Signed in as {user.email}

; ```
```tsx import { T, Var } from 'gt-tanstack-start';

Signed in as {user.email}

; ```
```tsx import { T, Var } from 'gt-react-native'; Signed in as {user.email} ; ```
## Format numbers and currency [#numbers] Use [``](/docs/react/reference/components/num) and [``](/docs/react/reference/components/currency) for locale-aware number and money formatting. Import both from your framework's package alongside [``](/docs/react/reference/components/t). ### Format a number Use [``](/docs/react/reference/components/num) for decimal grouping, percentages, and units. Pass [`options`](/docs/react/reference/components/num#options) to customize the output. ```tsx

{count} downloads are complete.

; ``` ```tsx {completionRate} ``` ### Format currency Use [``](/docs/react/reference/components/currency) with an ISO 4217 [`currency`](/docs/react/reference/components/currency#currency) code such as `USD` or `EUR`. ```tsx

Your total is {total}.

; ``` [``](/docs/react/reference/components/currency) defaults to `USD`, but passing [`currency`](/docs/react/reference/components/currency#currency) makes the intended unit explicit. It localizes the symbol, grouping, and decimal display; it does not convert exchange rates. Pass [`options`](/docs/react/reference/components/currency#options) to control details such as currency display, rounding, and notation. ## Format dates and times [#dates] Use [``](/docs/react/reference/components/datetime) for absolute dates and times, and [``](/docs/react/reference/components/relative-time) for relative values such as "3 days ago." ### Format an absolute date or time Use [``](/docs/react/reference/components/datetime) for calendar dates and clock times. Pass [`options`](/docs/react/reference/components/datetime#options) to control the date style, time style, and time zone. ```tsx

Published{' '} {publishedAt} .

; ``` ### Format relative time Use [``](/docs/react/reference/components/relative-time) with a `Date` to select an appropriate unit automatically: ```tsx

Published {publishedAt}.

; ``` For a known offset, pass [`value`](/docs/react/reference/components/relative-time#value) and [`unit`](/docs/react/reference/components/relative-time#unit) instead: ```tsx ``` Pass [`options`](/docs/react/reference/components/relative-time#options) to choose numeric or natural wording and a long, short, or narrow style. To override the active locale, choose the component you are formatting: - [`` `locales`](/docs/react/reference/components/num#locales) - [`` `locales`](/docs/react/reference/components/currency#locales) - [`` `locales`](/docs/react/reference/components/datetime#locales) - [`` `locales`](/docs/react/reference/components/relative-time#locales) ## Next steps - /docs/react/guides/handling-plurals-and-branches - /docs/react/guides/translating-jsx - /docs/react/guides/translating-strings - /docs/react/guides/managing-locales