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 |
浏览器兼容性
加载中…