# gt-next: General Translation Next.js SDK: DateTime URL: https://generaltranslation.com/en-US/docs/next/api/components/datetime.mdx --- title: DateTime description: API reference for the DateTime component --- {/* AUTO-GENERATED: Do not edit directly. Edit the template in content/docs-templates/ instead. */} ## Overview The `` component renders a formatted date or time string, supporting customization such as formatting options and locale. The date or time is formatted according to the current locale and any optional parameters passed. ```jsx {1738010355} // Output: 1/27/2025 ``` All formatting is handled locally using the [`Intl.DateTimeFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) library. ## Reference ### Props ### Description | Prop Name | Description | |-----------|-------------| | `children` | The content to render inside the component. Typically a date or time value. If provided, it takes precedence over the `value` prop. | | `value` | The default value for the date or time. Can be a string, number (timestamp), or Date object. | | `options` | Optional formatting options for the date or time, following the [`Intl.DateTimeFormatOptions` specification](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat). Use this to define styles such as weekday names, time zones, and more. | | `locales` | Optional locales to specify the formatting locale. If not provided, the user's locale is used. Read more about specifying locales [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument).| ### Returns `JSX.Element` containing the formatted date or time as a string. --- ## Examples ### Basic usage The `` component can be used to display localized date or time values. ```jsx title="EventDate.jsx" copy import { DateTime } from 'gt-next'; export default function EventDate(event) { return ( {event.date} . // [!code highlight] ); } ``` ### Specifying locales The `` component can be used to display date or time values in a specific locale. ```jsx title="EventDate.jsx" copy import { DateTime } from 'gt-next'; export default function EventDate(event) { return ( {event.date} . // [!code highlight] ); } ``` ### Translating DateTime Say that you want the datetime to be displayed in a sentence that is also being translated. You can wrap the `` component in a `` component. ```jsx title="EventDate.jsx" copy import { T, DateTime } from 'gt-next'; export default function EventDate(event) { return ( The time of the event is {event.date} . // [!code highlight] ); } ``` ### Custom formatting The `` component supports custom formatting options. ```jsx title="EventDate.jsx" copy import { DateTime } from 'gt-next'; export default function EventDate(event) { return ( {event.date} . ); } ``` --- ## Notes * The `` component is a variable component that can be used to format date and time values. * The component uses the [`Intl.DateTimeFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) library for formatting. ## Next steps * For more details and usage examples of the `` component and other variable components like ``, ``, and ``, see the [Using Variable Components](/docs/next/guides/variables) documentation.