Monday, November 18, 2024
Google search engine
HomeLanguagesJavascriptJavaScript Intl DateTimeFormat resolvedOptions() Method

JavaScript Intl DateTimeFormat resolvedOptions() Method

The Intl.DateTimeFormat.prototype.resolvedOptions() method is an inbuilt method in JavaScript that returns a new object with properties reflecting the locale, date, and time formatting options computed during the 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.

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

Example 1: This example shows the use of the Intl.DateTimeFormat.prototype.resolvedOptions() method in Javascript.

javascript




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


Output: 

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

Example 2: This example shows the use of the Intl.DateTimeFormat.prototype.resolvedOptions() method in Javascript.

javascript




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


Output: 

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

We have a complete list of Javascript Intl methods, to check those please go through the Javascript Intl Complete Reference article.

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

  • Google Chrome 24 and above
  • Edge 12 and above
  • Firefox 29 and above
  • Opera 15 and above
  • Safari 10 and above
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments