Home

IntlDateTimeFormatlocales

Intl.DateTimeFormat is a constructor in the ECMAScript Internationalization API (ECMA-402) that formats date and time values according to a specified locale and formatting options. It enables locale-sensitive representation of dates and times, taking into account language, region, time zone, and calendar conventions.

Creation and locales: The formatter is created with new Intl.DateTimeFormat(locales, options). The locales parameter can be

Formatting options: Options control which parts of the date and time are shown and how they are

Methods: The object provides format(date) to produce a localized string for a given Date, and formatToParts(date)

Usage notes: Intl.DateTimeFormat is widely supported in modern browsers and Node.js (as part of ECMA-402). It

a
string
such
as
"en-US"
or
an
array
of
locale
strings.
If
omitted,
the
environment’s
default
locale
is
used.
The
options
object
can
influence
how
components
of
a
date
and
time
are
presented.
styled.
Common
options
include
year,
month,
day,
weekday,
hour,
minute,
second,
timeZone,
timeZoneName,
era,
calendar,
numberingSystem,
and
hour12.
Values
such
as
'numeric',
'2-digit',
'long',
'short',
or
'narrow'
determine
the
level
of
detail
and
typography.
The
timeZone
option
selects
a
time
zone
like
"UTC"
or
"America/New_York",
and
timeZoneName
can
produce
a
short
or
long
designation.
to
return
a
structured
array
of
date-time
parts
(e.g.,
year,
month,
day,
literal
text).
resolvedOptions()
returns
the
resolved
locale,
calendar,
numbering
system,
and
other
active
settings
for
the
instance.
is
useful
for
producing
user-friendly
dates
and
times
in
multilingual
applications
and
can
be
combined
with
supportedLocalesOf
to
detect
locale
support.