Format Date
<cs-format-date>
Formats a date or time for display using the specified locale and options. Powered by the Intl.DateTimeFormat API for consistent, localized output.
Localization is handled by the browser’s Intl.DateTimeFormat API. No language packs are required.
The date attribute determines the date/time to use when formatting. It must be a string that Date.parse() can interpret or a Date object set via JavaScript. If omitted, the current date/time will be assumed.
Always use ISO 8601 date strings.
Ambiguous formats like 03/04/2020 can be read as March 4 or April 3 depending on the user’s browser and locale. A valid ISO 8601 date time string parses the same for every client.
Examples
Date & Time Format
Formatting options are based on those found in the Intl.DateTimeFormat API. When formatting options are provided, the date/time will be formatted according to those values. When no formatting options are provided, a localized, numeric date will be displayed instead.
Hour Format
By default, the browser will determine whether to use 12-hour or 24-hour time. To force one or the other, set the hour-format attribute to 12 or 24.
Localization
Use the lang attribute to set the date/time formatting locale.
French:
Russian:
API
Importing
If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.
import '@cruglobal/cornerstone-components/components/format-date/format-date.js';
import './cornerstone/components/format-date/format-date.js';
import CsFormatDate from '@cruglobal/cornerstone-components/react/format-date/index.js';
Attributes & Properties
Learn more about attributes and properties.
| Property | Attribute | Description | Type | Default | Reflects |
|---|---|---|---|---|---|
date | date | The date/time to format. If not set, the current date and time will be used. When passing a string, it's strongly recommended to use the ISO 8601 format to ensure timezones are handled correctly. To convert a date to this format in JavaScript, use date.toISOString(). | Date | string | new Date() | — |
day | day | The format for displaying the day. | 'numeric' | '2-digit' | — | — |
era | era | The format for displaying the era. | 'narrow' | 'short' | 'long' | — | — |
hour | hour | The format for displaying the hour. | 'numeric' | '2-digit' | — | — |
hourFormat | hour-format | The format for displaying the hour. | 'auto' | '12' | '24' | 'auto' | — |
minute | minute | The format for displaying the minute. | 'numeric' | '2-digit' | — | — |
month | month | The format for displaying the month. | 'numeric' | '2-digit' | 'narrow' | 'short' | 'long' | — | — |
second | second | The format for displaying the second. | 'numeric' | '2-digit' | — | — |
timeZone | time-zone | The time zone to express the time in. | string | — | — |
timeZoneName | time-zone-name | The format for displaying the time. | 'short' | 'long' | — | — |
weekday | weekday | The format for displaying the weekday. | 'narrow' | 'short' | 'long' | — | — |
year | year | The format for displaying the year. | 'numeric' | '2-digit' | — | — |

