formatDate
Playground
call
result
Signature
Section titled “Signature”formatDate(value: string, locale?: string, options?: DateTimeFormatOptions): stringimport { formatDate } from "@northguild/gmt/plain/format";Return a localized string for a PlainDate ISO input using Intl options.
- Uses Temporal.PlainDate.toLocaleString for formatting.
- Accepts optional BCP 47 locale and Intl.DateTimeFormatOptions.
- Returns “” for invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string |
ISO PlainDate string |
locale |
string |
optional BCP 47 locale identifier |
Options
Section titled “Options”options
| Option | Type | Default |
|---|---|---|
localeMatcher? |
"best fit" | "lookup" |
— |
weekday? |
"long" | "short" | "narrow" |
— |
era? |
"long" | "short" | "narrow" |
— |
year? |
"numeric" | "2-digit" |
— |
month? |
"long" | "short" | "narrow" | "numeric" | "2-digit" |
— |
day? |
"numeric" | "2-digit" |
— |
hour? |
"numeric" | "2-digit" |
— |
minute? |
"numeric" | "2-digit" |
— |
second? |
"numeric" | "2-digit" |
— |
timeZoneName? |
"long" | "short" | "shortOffset" | "longOffset" | "shortGeneric" | "longGeneric" |
— |
formatMatcher? |
"best fit" | "basic" |
— |
hour12? |
boolean |
— |
timeZone? |
string |
— |
calendar? |
string |
— |
dayPeriod? |
"long" | "short" | "narrow" |
— |
numberingSystem? |
string |
— |
dateStyle? |
"long" | "short" | "medium" | "full" |
— |
timeStyle? |
"long" | "short" | "medium" | "full" |
— |
hourCycle? |
"h11" | "h12" | "h23" | "h24" |
— |
fractionalSecondDigits? |
1 | 2 | 3 |
— |
Returns
Section titled “Returns”localized date string or “” on invalid input
Examples
Section titled “Examples”formatDate("2024-03-15", "en-US", { year: "numeric", month: "long", day: "numeric" }) // "March 15, 2024"formatDate("2024-03-15", "de-DE", { year: "numeric", month: "long", day: "numeric" }) // "15. März 2024"formatDate("invalid") // ""