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
.
zonedDateTimeISO: (tzLike?: TimeZoneLike) => Temporal.ZonedDateTime
Get the current calendar date and clock time in a specific time zone, using the ISO 8601 calendar.
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.
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"