JavaScript Intl.DateTimeFormat Object
Intl.DateTimeFormat formats dates and times for a chosen language and region, with options for styles, parts and time zones.
Description
Intl.DateTimeFormat creates a formatter for dates and times that follows the conventions of a locale: the order of day, month and year, month names, 12- or 24-hour clocks and so on. Options include dateStyle and timeStyle ('full', 'long', 'medium' or 'short'), individual parts such as weekday, month and hour, and timeZone to show a time in another zone.
Call format(date) for a string, formatToParts() to get the pieces separately for custom styling, and formatRange() for ranges such as "28 Nov - 2 Dec".
All the formatting is done by the browser using its built-in locale data, so you don't need a date library just to display dates. Calling resolvedOptions() on a formatter tells you which locale, calendar and time zone it actually ended up using, which is the standard way to detect the user's time zone: Intl.DateTimeFormat().resolvedOptions().timeZone.
Creating
new Intl.DateTimeFormat(locales, options)Example
Browser Support
The following information will show you the current browser support for the Intl.DateTimeFormat object. Hover over a browser icon to see the version that first introduced support for this object.
Desktop





Tablets & Mobile





