Formatted Date
Present dates and times in a clear, user-friendly format that reflects their locale.
#Examples
Consistently display dates and times in a clear, accessible format that aligns with user expectations and regional conventions. This ensures clarity and avoids confusion when presenting temporal information.
Examples:
- Scheduled reports: 6/25/2024, 02:51 PM
- User action log: 7/3/2024 4:28:44 PM
- User creation date: 25/03/2024
- Last Updated: 2 hours ago
<FormattedDate date={date} locale="en-US" />
#Format
Choose the format that best suits the content type and context.
- Date: Prioritize unambiguous formats (e.g., "March 25, 2024" or "25 March 2024"). For brevity, consider using abbreviated month names only if space is limited and the context is clear. See examples in Grammar and mechanics > Dates.
- Time: Use the 12-hour clock (AM/PM) for clarity, especially in less formal contexts. See examples in Grammar and mechanics > Times.
<FormattedDate date={date} locale="en-US" format="time" />
<br />
<FormattedDate date={date} locale="en-US" format="date" />
<br />
<FormattedDate date={date} locale="en-US" format="datetime" />
#Locale
The date and time display pattern varies with each region of the globe. Therefore, the locale parameter allows you to control in which standard the date will be formatted. All standard locale codes defined by the ECMAScript Internationalization API are supported.
<FormattedDate date={date} locale="da-DK" format="datetime" />
<br />
<FormattedDate date={date} locale="en-US" format="datetime" />
<br />
<FormattedDate date={date} locale="pt-BR" format="datetime" />
#Timezone Reset
By default, dates are displayed in UTC. However, this behavior can be changed to display them in your local timezone.
<FormattedDate date={date} locale="en-US" format="datetime" skipTimezoneReset />
#Empty date
When no date or time is available, use a clear placeholder (e.g., "-") and provide an appropriate aria-label for screen reader users (e.g., "Date unavailable").
<FormattedDate date={null} locale="en-US" />
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications