Temporal.Now.plainDateISO()
Temporal.Now.plainDateISO() 靜態方法以 ISO 8601 日曆和指定時區,返回當前日期,格式為 Temporal.PlainDate 物件。
語法
js
Temporal.Now.plainDateISO()
Temporal.Now.plainDateISO(timeZone)
引數
timeZone可選-
可以是代表解釋系統時間的時區的字串或
Temporal.ZonedDateTime例項。如果是 Temporal.ZonedDateTime 例項,則使用其時區。如果是字串,可以是命名時區識別符號、偏移時區識別符號,或包含時區識別符號或偏移量的日期時間字串(有關更多資訊,請參閱 時區和偏移量)。
返回值
以 ISO 8601 日曆格式,在指定時區中,返回當前日期,格式為 Temporal.PlainDate 物件。
異常
RangeError-
如果時區無效,則丟擲此異常。
示例
使用 Temporal.Now.plainDateISO()
js
// The current date in the system's time zone
const date = Temporal.Now.plainDateISO();
console.log(date); // e.g.: 2021-10-01
// The current date in the "America/New_York" time zone
const dateInNewYork = Temporal.Now.plainDateISO("America/New_York");
console.log(dateInNewYork); // e.g.: 2021-09-30
規範
| 規範 |
|---|
| Temporal # sec-temporal.now.plaindateiso |
瀏覽器相容性
載入中…