JavaScript | Intl.DateTimeFormat.prototype.resolvedOptions() Method

The Intl.DateTimeFormat.prototype.resolvedOptions() method is an inbuilt method in JavaScript which returns a new object with properties reflecting the locale, date and time formatting options computed during initialization of this DateTimeFormat object.

Syntax:

dateTimeFormat.resolvedOptions()

Parameters: This method does not accept any parameters.



Return value: This method returns a new object with properties reflecting the locale and date and time.

Below examples illustrate the Intl.DateTimeFormat.prototype.resolvedOptions() method in JavaScript:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

const geeks = new Intl.DateTimeFormat('zh-CN', { timeZone: 'UTC' });
const result = geeks.resolvedOptions();
console.log(result.locale);
console.log(result.calendar);
console.log(result.timeZone);
  
const geeks1 = new Intl.DateTimeFormat('LT');
const result1 = geeks1.resolvedOptions();
console.log(result1.locale);
console.log(result1.calendar);

chevron_right


Output:

"zh-CN"
"gregory"
"UTC"
"lt"
"gregory"

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

var geeks = new Intl.DateTimeFormat('de-XX', { timeZone: 'UTC' });
var result = geeks.resolvedOptions();
  
console.log(result.locale);       
console.log(result.calendar);       
console.log(result.numberingSystem); 
console.log(result.timeZone);        
console.log(result.month); 

chevron_right


Output:

"de"
"gregory"
"latn"
"UTC"
"numeric"

Supported Browsers: The browsers supported by Intl.DateTimeFormat.prototype.resolvedOptions() method are listed below:

  • Google Chrome
  • Edge
  • Firefox
  • Opera
  • Safari

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.