The Temporal.Now
object has several methods which give information about
the current date, time, and time zone.
See https://tc39.es/proposal-temporal/docs/now.html for more details.
instant: () => Temporal.Instant
Get the exact system date and time as a Temporal.Instant
.
This method gets the current exact system time, without regard to
calendar or time zone. This is a good way to get a timestamp for an
event, for example. It works like the old-style JavaScript Date.now()
,
but with nanosecond precision instead of milliseconds.
Note that a Temporal.Instant
doesn't know about time zones. For the
exact time in a specific time zone, use Temporal.Now.zonedDateTimeISO
or Temporal.Now.zonedDateTime
.
zonedDateTime: (calendar: CalendarLike,tzLike?: TimeZoneLike,) => Temporal.ZonedDateTime
Get the current calendar date and clock time in a specific calendar and time zone.
The calendar
parameter is required. When using the ISO 8601 calendar or
if you don't understand the need for or implications of a calendar, then
a more ergonomic alternative to this method is
Temporal.Now.zonedDateTimeISO()
.
zonedDateTimeISO: (tzLike?: TimeZoneLike) => Temporal.ZonedDateTime
Get the current calendar date and clock time in a specific time zone, using the ISO 8601 calendar.
plainDateTime: (calendar: CalendarLike,tzLike?: TimeZoneLike,) => Temporal.PlainDateTime
Get the current calendar date and clock time in a specific calendar and time zone.
The calendar is required. When using the ISO 8601 calendar or if you
don't understand the need for or implications of a calendar, then a more
ergonomic alternative to this method is Temporal.Now.plainDateTimeISO
.
Note that the Temporal.PlainDateTime
type does not persist the time zone,
but retaining the time zone is required for most time-zone-related use
cases. Therefore, it's usually recommended to use
Temporal.Now.zonedDateTimeISO
or Temporal.Now.zonedDateTime
instead
of this function.
plainDateTimeISO: (tzLike?: TimeZoneLike) => Temporal.PlainDateTime
Get the current date and clock time in a specific time zone, using the ISO 8601 calendar.
Note that the Temporal.PlainDateTime
type does not persist the time zone,
but retaining the time zone is required for most time-zone-related use
cases. Therefore, it's usually recommended to use
Temporal.Now.zonedDateTimeISO
instead of this function.
plainDate: (calendar: CalendarLike,tzLike?: TimeZoneLike,) => Temporal.PlainDate
Get the current calendar date in a specific calendar and time zone.
The calendar is required. When using the ISO 8601 calendar or if you
don't understand the need for or implications of a calendar, then a more
ergonomic alternative to this method is Temporal.Now.plainDateISO
.
plainDateISO: (tzLike?: TimeZoneLike) => Temporal.PlainDate
Get the current date in a specific time zone, using the ISO 8601 calendar.
plainTimeISO: (tzLike?: TimeZoneLike) => Temporal.PlainTime
Get the current clock time in a specific time zone, using the ISO 8601 calendar.
timeZoneId: () => string
Get the identifier of the environment's current time zone.
This method gets the identifier of the current system time zone. This will usually be a named IANA time zone.
[[Symbol.toStringTag]]: "Temporal.Now"