The Intl.DateTimeFormat object can be used for language-sensitive date and time formatting in JavaScript. It is available in all modern browsers and IE 11.

The Intl.DateTimeFormat object provides the format() method that formats a date according to the locale and formatting options of the DateTimeFormat object.

Here is an example that uses the default locale and default options:

let date = new Date(Date.UTC(2021, 9, 6, 8, 26))

let dateStr = new Intl.DateTimeFormat().format(date)

console.log(dateStr) 
// 10/6/2021

Using locales

For localized date and time formats, you can pass the desired language to the Intl.DateTimeFormat() constructor as shown below:

let date = new Date(Date.UTC(2021, 9, 6, 8, 26))

console.log(new Intl.DateTimeFormat('en-GB').format(date))
// 06/10/2021

console.log(new Intl.DateTimeFormat('ko-KR').format(date))
// 2021. 10. 6.

console.log(new Intl.DateTimeFormat('ar-EG').format(date))
// ٦‏/١٠‏/٢٠٢١

Using options

You can customize the date and time formats using the options argument:

let date = new Date(Date.UTC(2021, 9, 6, 8, 26))

const options = {
    weekday: 'long',
    year: 'numeric',
    month: 'long',
    day: 'numeric'
}

console.log(new Intl.DateTimeFormat('fr-FR', options).format(date))
// mercredi 6 octobre 2021

options.timeZone = 'EST'
options.timeZoneName = 'short'

console.log(new Intl.DateTimeFormat('en-US', options).format(date))
// Wednesday, October 6, 2021, GMT-5

options.fractionalSecondDigits = 3

console.log(new Intl.DateTimeFormat('en-AU', options).format(date))
// Wednesday, 6 October 2021, 000 GMT-5