deno.com

method Intl.DateTimeFormat.formatToParts

#DateTimeFormat.formatToParts(date?: Formattable | number): globalThis.Intl.DateTimeFormatPart[]

Allow locale-aware formatting of strings produced by Intl.DateTimeFormat formatters.

Examples #

#
const formatter = new Intl.DateTimeFormat('en-US', { dateStyle: 'full' });
const date = new Date(2023, 0, 1);
console.log(formatter.format(date)); // Output: "Sunday, January 1, 2023"

Parameters #

#date: Formattable | number
optional

Return Type #

globalThis.Intl.DateTimeFormatPart[]