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