Home

formatToPartsdate

formatToPartsdate is commonly understood as a misnomer for the Intl.DateTimeFormat.formatToParts method, a function in the ECMA-402 internationalization API. There is no standard API named formatToPartsdate; formatToParts is the correct method name. It formats a date according to a specified locale and options and returns the result as an array of parts rather than a single string.

The formatToParts method belongs to Intl.DateTimeFormat. Its usage involves creating a formatter with a locale and

Common scenarios include extracting individual date parts for custom assembly, localization testing, or supplying parts to

Example usage (conceptual): a formatter for en-US with numeric year, two-digit month, and two-digit day may produce

FormatToParts is broadly supported in modern browsers and environments implementing the ECMA-402 API. For older runtimes,

formatting
options,
then
calling
formatToParts
with
a
Date
object
or
a
numeric
timestamp.
The
returned
value
is
an
array
where
each
element
is
an
object
with
a
type
and
a
value.
The
type
indicates
the
kind
of
date/time
component
(for
example
year,
month,
day,
hour,
minute,
second,
dayPeriod,
weekday,
era),
or
it
can
be
a
literal
string
that
should
appear
as-is
in
the
final
result.
The
exact
set
of
types
depends
on
the
locale
and
options
chosen.
a
rendering
system
that
builds
its
own
UI.
Because
formatToParts
is
locale-aware,
the
sequence
and
formatting
of
parts
can
vary
between
languages
and
scripts,
unlike
a
fixed
date
string.
parts
like
[{type:'month',
value:'09'},{type:'literal',
value:'/'},{type:'day',
value:'08'},{type:'literal',
value:'/'},{type:'year',
value:'2024'}].
The
exact
output
depends
on
locale
and
options.
availability
may
vary.