Use for displaying a date or time formatted for the user's language.
The q2-formatted-date element has one or more properties that support text localization. Those properties are indicated by the localizable badge in the description.
dateThe date to format, as a Date object or an ISO 8601 string.
Strings must use ISO 8601 date (YYYY-MM-DD) or date-time (YYYY-MM-DDTHH:mm, with optional seconds and a Z
or ±HH:mm offset) format. If the provided date is invalid, the invalidDateMessage will display.
2026-05-05) is a calendar date and displays as that same date in every time zone.Date object or a date-time string (e.g. 2026-05-05T14:30:00-05:00) is an exact moment in time and
displays in the user's time zone, unless options.timeZone is set.invalidDateMessageinvalid-date-messageThe message displayed when date is invalid. Set to an empty string to display nothing.
localeThe language used to format the date, as a BCP 47 language tag (e.g. en-US).
If locale is not set or is not supported, the page's lang is used, then the browser's default language.
optionsFormatting options passed to Intl.DateTimeFormat, such as dateStyle, timeStyle, month, or timeZone.
Set this property in JavaScript; it cannot be set as an HTML attribute.
element.options = { dateStyle: 'long' }; // May 4, 2026
element.options = { dateStyle: 'medium', timeStyle: 'short' }; // May 4, 2026, 2:30 PMIf the options are invalid, the default options are used instead and a warning message will be printed in the console.
timeStyle (or hour and minute) and provide a Date object or a date-time string.
A date-only string has no time, so time options are ignored for it and only the date is shown.sizeApplies a display size to the date. If no size is provided, the date inherits the font size, weight, and color of the surrounding text.
The q2-formatted-date element exposes methods that can be used to perform various actions on the component.
Retrieves the displayed text.
displayedMessageValue() => Promise<string>date accepts a Date object or an ISO 8601 string. The kind of value you pass decides how the date reacts to the user's time zone.
2026-05-04): a calendar date. It displays as the same day in every time zone. Use this for due dates, birthdays, and other days that have no time attached.Date object or date-time string (2026-05-04T02:00:00Z): an exact moment in time. It displays in the user's time zone, so the calendar day can differ from one user to the next.Your loan payment is due
Your transfer was sent
<p>Your loan payment is due <q2-formatted-date date="2026-05-04"></q2-formatted-date>.</p>
<p>Your transfer was sent <q2-formatted-date date="2026-05-04T02:00:00Z"></q2-formatted-date>.</p>
The transfer was sent at 2:00 AM UTC on May 4, which is still the evening of May 3 in US time zones, so US users see May 3.
Strings must use an ISO 8601 date (YYYY-MM-DD) or date-time (YYYY-MM-DDTHH:mm, with optional seconds and a Z or ±HH:mm offset). Any other string, such as May 4, 2026 or 2026-05, is treated as an invalid date.
Set options in JavaScript with any Intl.DateTimeFormat options. It can't be set as an HTML attribute. To change the format later, assign a new object; changing a property on the existing object won't update the component.
<q2-formatted-date id="options-long" date="2026-05-04"></q2-formatted-date>
<br />
<q2-formatted-date id="options-parts" date="2026-05-04"></q2-formatted-date>
<script>
document.getElementById('options-long').options = { dateStyle: 'long' };
document.getElementById('options-parts').options = { weekday: 'long', month: 'long', day: 'numeric' };
</script>
Add timeStyle (or hour and minute) to show a time. Pass a Date object or a date-time string; a date-only string has no time, so time options are ignored for it and only the date is shown.
To show the time in a specific time zone, such as your institution's, set timeZone. Otherwise the time displays in the user's time zone.
<q2-formatted-date id="time-local" date="2026-05-04T14:30:00Z"></q2-formatted-date>
<br />
<q2-formatted-date id="time-chicago" date="2026-05-04T14:30:00Z"></q2-formatted-date>
<script>
document.getElementById('time-local').options = { dateStyle: 'medium', timeStyle: 'short' };
document.getElementById('time-chicago').options = {
dateStyle: 'medium',
timeStyle: 'long',
timeZone: 'America/Chicago',
};
</script>
locale takes a BCP 47 language tag. When locale isn't set or isn't supported, the component uses the page's lang, then the browser's default language. An unsupported locale also prints a warning in the console.
<q2-formatted-date date="2026-05-04" locale="en-US"></q2-formatted-date>
<br />
<q2-formatted-date date="2026-05-04" locale="de-DE"></q2-formatted-date>
<br />
<q2-formatted-date date="2026-05-04" locale="zh-CN"></q2-formatted-date>
Without size, the date inherits the font size, weight, and color of the text around it, so it fits naturally in a sentence. Use small, medium, or large for a standalone display date.
Statement period ending
<p>Statement period ending <q2-formatted-date date="2026-05-04"></q2-formatted-date></p>
<q2-formatted-date date="2026-05-04" size="small"></q2-formatted-date>
<br />
<q2-formatted-date date="2026-05-04" size="medium"></q2-formatted-date>
<br />
<q2-formatted-date date="2026-05-04" size="large"></q2-formatted-date>
When date is missing or invalid, the component shows "Invalid Date" and prints a warning in the console. Use invalidDateMessage to show your own text, or set it to an empty string to show nothing.
<q2-formatted-date date="not-a-date"></q2-formatted-date>
<br />
<q2-formatted-date date="not-a-date" invalid-date-message="Date unavailable"></q2-formatted-date>
invalidDateMessage is localizable, so it also accepts a localization key. To change the default message for every instance in your extension, override tecton.element.formattedDate.invalidDate in your extension's language files.
The formatted text renders inside the component's shadow root. Call displayedMessageValue() to read the text the component is displaying, including the invalid date message.
const formattedDate = document.querySelector('q2-formatted-date');
const text = await formattedDate.displayedMessageValue(); // "5/4/2026"
The following CSS variables are available to override the default theme styles of the q2-formatted-date component.
The changelog provides a detailed history of new features, improvements, and bug fixes going back to Tecton 1.30.0. If the button is disabled, it indicates there have been no detectable changes since then.