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 InstantThe 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 ZonedDateTimeCurrent 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 ZonedDateTimeCurrent 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 PlainDateCurrent 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 PlainDateCurrent 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 PlainDateTimeCurrent 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 PlainDateTimeCurrent 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 PlainTimeCurrent 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 PlainTimeCurrent 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 StringThe 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
- Modules
- JS.
Temporal. Duration - JS.
Temporal. Duration. Internal - JS.
Temporal. Instant - JS.
Temporal. Instant. Internal - JS.
Temporal. Internal - JS.
Temporal. Now - JS.
Temporal. Options. CalendarName - JS.
Temporal. Options. Disambiguation - JS.
Temporal. Options. OffsetDisambiguation - JS.
Temporal. Options. Overflow - JS.
Temporal. Options. RoundingMode - JS.
Temporal. Options. TemporalUnit - JS.
Temporal. PlainDate - JS.
Temporal. PlainDate. Internal - JS.
Temporal. PlainDateTime - JS.
Temporal. PlainDateTime. Internal - JS.
Temporal. PlainMonthDay - JS.
Temporal. PlainMonthDay. Internal - JS.
Temporal. PlainTime - JS.
Temporal. PlainTime. Internal - JS.
Temporal. PlainYearMonth - JS.
Temporal. PlainYearMonth. Internal - JS.
Temporal. ZonedDateTime - JS.
Temporal. ZonedDateTime. Internal