このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

Intl.DateTimeFormat.prototype.resolvedOptions()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2017年9月⁩.

Intl.DateTimeFormat.prototype.resolvedOptions() メソッドは、この Intl/DateTimeFormat オブジェクトの初期化時に計算されたロケールや日付と時刻の整形オプションを反映したプロパティを持つ新しいオブジェクトを返します。

試してみましょう

const region1 = new Intl.DateTimeFormat("zh-CN", { timeZone: "UTC" });
const options1 = region1.resolvedOptions();

console.log(options1.locale);
// Expected output: "zh-CN"

console.log(options1.calendar);
// Expected output: "gregory"

console.log(options1.numberingSystem);
// Expected output: "latn"

構文

js
resolvedOptions();

返値

この Intl/DateTimeFormat オブジェクトの初期化時に計算されたロケールと照合オプションを反映したプロパティを持つ新しいオブジェクトです。

解説

返されるオブジェクトには以下のプロパティがあります。

locale

実際に使用したロケールの BCP 47 言語タグ。このロケールにつながる入力 BCP 47 言語タグに Unicode 拡張値が要求された場合、要求されたキーと値のペアのうち、このロケールで対応しているものが locale に含まれます。

calendar

例: "gregory"

numberingSystem

Unicode 拡張キーの "ca" および "nu" で要求された値、または既定値が入ります。

timeZone

options 引数の同名のプロパティで要求された値です。提供された値がなければ undefined (ランタイムの既定のタイムゾーン) です。警告: アプリケーションは undefined が返されることに依存しないでください。将来のバージョンではランタイムの既定のタイムゾーンを識別する String 値が返されるようになる可能性があるからです。

hour12

options 引数の同名のプロパティで要求された値、または既定値が入ります。

weekday, era, year, month, day, hour, minute, second, timeZoneName

options 引数の対応するプロパティと、選択したロケールでの日付時刻の書式設定に利用可能な組み合わせや表現との間で、書式のマッチングを行った結果の値。これらのプロパティの中には、対応するコンポーネントが書式化された出力では表現されないものもあります。

resolvedOptions メソッドの使用

js
var germanFakeRegion = new Intl.DateTimeFormat("de-XX", { timeZone: "UTC" });
var usedOptions = germanFakeRegion.resolvedOptions();

usedOptions.locale; // "de"
usedOptions.calendar; // "gregory"
usedOptions.numberingSystem; // "latn"
usedOptions.timeZone; // "UTC"
usedOptions.month; // "numeric"

仕様書

Specification
ECMAScript® 2026 Internationalization API Specification
# sec-intl.datetimeformat.prototype.resolvedoptions

ブラウザーの互換性

関連情報