JavaScript

Intl.DateTimeFormat.prototype.resolvedOptions() メソッド


編集:2023.01.09 by T.A.

[Edge]。→

Intl.DateTimeFormat により日時の書式化に関与するプロパティと値のオブジェクトを返します。

構文
Intl.DateTimeFormat.resolvedOptions()
Intl.DateTimeFormat Intl.DateTimeFormat
戻り値

関与するプロパティと値のオブジェクト。

プロパティと取得値:
calendar
Intl.DateTimeFormat():calendar

値例: 「gregory」

dateStyle
Intl.DateTimeFormat():dateStyle

値例: 「long」。

day
Intl.DateTimeFormat():day
era
Intl.DateTimeFormat():era
fractionalSecondDigits
Intl.DateTimeFormat():fractionalSecondDigits

値例: 2(数値)

hour
Intl.DateTimeFormat():hour
hour12
Intl.DateTimeFormat():hour12

値例: false(論理値)

hourCycle
Intl.DateTimeFormat():hourCycle

値例: 「h23」

locale
ロケールの言語タグとUnicode 拡張値。→

値例: 「ja-JP」

minute
Intl.DateTimeFormat():minute
month
Intl.DateTimeFormat():month
numberingSystem
Intl.DateTimeFormat():numberingSystem

値例: 「latn」

second
Intl.DateTimeFormat():second
timeStyle
Intl.DateTimeFormat():timeStyle

値例: 「long」

timeZone
Intl.DateTimeFormat():timeZone

値例: 「Asia/Tokyo」

timeZoneName
Intl.DateTimeFormat():timeZoneName
year
Intl.DateTimeFormat():year
weekday
Intl.DateTimeFormat():weekday
//●
DA=new Intl.DateTimeFormat('ja-JP', {dateStyle:'long'});  //日付
D=DA.resolvedOptions();  //=[object]:[object Object]
	//locale=[string]:ja-JP
	//calendar=[string]:gregory
	//numberingSystem=[string]:latn
	//timeZone=[string]:Asia/Tokyo
	//dateStyle=[string]:long

DA=new Intl.DateTimeFormat('ja-JP', {timeStyle:'long'});  //時刻
D=DA.resolvedOptions();  //=[object]:[object Object]
	//locale=[string]:ja-JP
	//calendar=[string]:gregory
	//numberingSystem=[string]:latn
	//timeZone=[string]:Asia/Tokyo
	//hourCycle=[string]:h23
	//hour12=[boolean]:false
	//timeStyle=[string]:long

DA=new Intl.DateTimeFormat('ja-JP', {fractionalSecondDigits:2});  //ミリ秒
D=DA.resolvedOptions();  //=[object]:[object Object]
	//locale=[string]:ja-JP
	//calendar=[string]:gregory
	//numberingSystem=[string]:latn
	//timeZone=[string]:Asia/Tokyo
	//fractionalSecondDigits=[number]:2

Intl.DateTimeFormat() コンストラクター


テスト