JavaScript Intl DateTimeFormat resolvedOptions Method returns a new object with properties reflecting the locale and date and time formatting options computed during initialization of Intl.DateTimeFormat object.
This method can be useful for debugging or understanding what settings are actually being used by a particular DateTimeFormat instance, especially when default values are being filled in for unspecified options.
Syntax
Intl.DateTimeFormat.resolvedOptions()
Parameters
None.
Return Value
This method returns a new object containing the resolved options.
Example 1: How to Use JavaScript Intl DateTimeFormat resolvedOptions() Method
const dateTimeFormat = new Intl.DateTimeFormat('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
}).resolvedOptions();
console.log(dateTimeFormat);
Output
{
locale: 'en-US',
calendar: 'gregory',
numberingSystem: 'latn',
timeZone: 'Asia/Calcutta',
year: 'numeric',
month: 'long',
day: 'numeric'
}
Example 2: Using a Different Locale
const dateTimeFormat = new Intl.DateTimeFormat('fr-FR', {
year: 'numeric',
month: 'short',
day: '2-digit'
}).resolvedOptions();
console.log(dateTimeFormat);
Output
{
locale: 'fr-FR',
calendar: 'gregory',
numberingSystem: 'latn',
timeZone: 'Asia/Calcutta',
year: 'numeric',
month: 'short',
day: '2-digit'
}
Browser Compatibility
Chrome 24+ | Edge 12+ | Firefox 29+ | Safari 10+ | Opera 15+ |
Yes | Yes | Yes | Yes | Yes |
That’s it!
Related posts
JavaScript Int.DateTimeFormat() constructor
JavaScript Intl.DateTimeFormat.format() Method
JavaScript Intl DateTimeFormat formatRange() Method
JavaScript Intl DateTimeFormat formatRangeToParts() Method
JavaScript Intl DateTimeFormat supportedLocalesOf() Method
JavaScript Intl DateTimeFormat formatToParts() Method

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.