Module

JS.Temporal.Now

Package
purescript-js-temporal
Repository
pete-murphy/purescript-js-temporal

Methods to obtain the current time in various formats. Corresponds to the Temporal.Now namespace. All functions run in Effect and use the system's current time.

Functions with a trailing underscore use the system's local time zone. Functions without the underscore take an explicit time zone string.

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Now

#instant Source

instant :: Effect Instant

The current instant (nanoseconds since epoch).

locale <- JS.Intl.Locale.new_ "en-US"
now <- Now.instant
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long", timeStyle: "medium", timeZone: "UTC" }
Console.log ("Current instant (UTC): " <> JS.Intl.DateTimeFormat.format formatter now)
Current instant (UTC): March 8, 2026 at 7:47:31 PM

#zonedDateTimeISO_ Source

zonedDateTimeISO_ :: Effect ZonedDateTime

Current date and time in the system's local time zone.

locale <- JS.Intl.Locale.new_ "en-US"
now <- Now.zonedDateTimeISO_
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long", timeStyle: "medium" }
Console.log ("Now (zoned): " <> JS.Intl.DateTimeFormat.format formatter now)
Now (zoned): March 8, 2026 at 3:47:31 PM

#zonedDateTimeISO Source

zonedDateTimeISO :: String -> Effect ZonedDateTime

Current date and time in the given time zone.

locale <- JS.Intl.Locale.new_ "en-US"
nowUtc <- Now.zonedDateTimeISO "UTC"
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long", timeStyle: "medium", timeZone: "UTC" }
Console.log ("Now (UTC): " <> JS.Intl.DateTimeFormat.format formatter nowUtc)
Now (UTC): March 8, 2026 at 7:47:31 PM

#plainDateISO_ Source

plainDateISO_ :: Effect PlainDate

Current date in the system's local time zone.

locale <- JS.Intl.Locale.new_ "en-US"
today <- Now.plainDateISO_
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long" }
Console.log ("Today (local): " <> JS.Intl.DateTimeFormat.format formatter today)
Today (local): March 8, 2026

#plainDateISO Source

plainDateISO :: String -> Effect PlainDate

Current date in the given time zone.

locale <- JS.Intl.Locale.new_ "en-US"
todayUtc <- Now.plainDateISO "UTC"
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long" }
Console.log ("Today (UTC): " <> JS.Intl.DateTimeFormat.format formatter todayUtc)
Today (UTC): March 8, 2026

#plainDateTimeISO_ Source

plainDateTimeISO_ :: Effect PlainDateTime

Current date and time in the system's local time zone (plain, no zone).

locale <- JS.Intl.Locale.new_ "en-US"
now <- Now.plainDateTimeISO_
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long", timeStyle: "medium" }
Console.log ("Now (local): " <> JS.Intl.DateTimeFormat.format formatter now)
Now (local): March 8, 2026 at 3:47:31 PM

#plainDateTimeISO Source

plainDateTimeISO :: String -> Effect PlainDateTime

Current date and time in the given time zone (plain, no zone).

locale <- JS.Intl.Locale.new_ "en-US"
nowUtc <- Now.plainDateTimeISO "UTC"
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long", timeStyle: "medium" }
Console.log ("Now (UTC): " <> JS.Intl.DateTimeFormat.format formatter nowUtc)
Now (UTC): March 8, 2026 at 7:47:31 PM

#plainTimeISO_ Source

plainTimeISO_ :: Effect PlainTime

Current time in the system's local time zone.

locale <- JS.Intl.Locale.new_ "en-US"
time <- Now.plainTimeISO_
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { timeStyle: "medium" }
Console.log ("Current time (local): " <> JS.Intl.DateTimeFormat.format formatter time)
Current time (local): 3:47:31 PM

#plainTimeISO Source

plainTimeISO :: String -> Effect PlainTime

Current time in the given time zone.

locale <- JS.Intl.Locale.new_ "en-US"
timeUtc <- Now.plainTimeISO "UTC"
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { timeStyle: "medium" }
Console.log ("Current time (UTC): " <> JS.Intl.DateTimeFormat.format formatter timeUtc)
Current time (UTC): 7:47:31 PM

#timeZoneId Source

timeZoneId :: Effect String

The system's current time zone identifier (e.g. "America/New_York").

tz <- Now.timeZoneId
Console.log ("System time zone: " <> tz)
System time zone: America/New_York