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).
exampleInstant :: Effect Unit
exampleInstant = do
locale <- JS.Intl.Locale.new_ "en-US"
now <- Now.instant
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long", timeStyle: "medium", timeZone: "Africa/Monrovia" }
Console.log ("Current instant (Africa/Monrovia): " <> JS.Intl.DateTimeFormat.format formatter now)
Current instant (Africa/Monrovia): May 11, 2026 at 6:35:28 PM
#zonedDateTimeISO Source
zonedDateTimeISO :: Effect ZonedDateTimeCurrent date and time in the system's local time zone.
exampleZonedDateTimeISO :: Effect Unit
exampleZonedDateTimeISO = do
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): May 11, 2026 at 2:35:28 PM
#zonedDateTimeISOWithTimeZone Source
zonedDateTimeISOWithTimeZone :: String -> Effect ZonedDateTimeCurrent date and time in the given time zone.
exampleZonedDateTimeISOWithTimeZone :: Effect Unit
exampleZonedDateTimeISOWithTimeZone = do
locale <- JS.Intl.Locale.new_ "en-US"
nowUtc <- Now.zonedDateTimeISOWithTimeZone "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): May 11, 2026 at 6:35:28 PM
#plainDateISO Source
plainDateISO :: Effect PlainDateCurrent date in the system's local time zone.
examplePlainDateISO :: Effect Unit
examplePlainDateISO = do
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): May 11, 2026
#plainDateISOWithTimeZone Source
plainDateISOWithTimeZone :: String -> Effect PlainDateCurrent date in the given time zone.
examplePlainDateISOWithTimeZone :: Effect Unit
examplePlainDateISOWithTimeZone = do
locale <- JS.Intl.Locale.new_ "en-US"
todayTijuana <- Now.plainDateISOWithTimeZone "America/Tijuana"
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long" }
Console.log ("Today (America/Tijuana): " <> JS.Intl.DateTimeFormat.format formatter todayTijuana)
Today (America/Tijuana): May 11, 2026
#plainDateTimeISO Source
plainDateTimeISO :: Effect PlainDateTimeCurrent date and time in the system's local time zone (plain, no zone).
examplePlainDateTimeISO :: Effect Unit
examplePlainDateTimeISO = do
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): May 11, 2026 at 2:35:28 PM
#plainDateTimeISOWithTimeZone Source
plainDateTimeISOWithTimeZone :: String -> Effect PlainDateTimeCurrent date and time in the given time zone (plain, no zone).
examplePlainDateTimeISOWithTimeZone :: Effect Unit
examplePlainDateTimeISOWithTimeZone = do
locale <- JS.Intl.Locale.new_ "en-US"
nowUtc <- Now.plainDateTimeISOWithTimeZone "UTC"
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long", timeStyle: "medium" }
Console.log ("Now (UTC): " <> JS.Intl.DateTimeFormat.format formatter nowUtc)
Now (UTC): May 11, 2026 at 6:35:28 PM
#plainTimeISO Source
plainTimeISO :: Effect PlainTimeCurrent time in the system's local time zone.
examplePlainTimeISO :: Effect Unit
examplePlainTimeISO = do
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): 2:35:28 PM
#plainTimeISOWithTimeZone Source
plainTimeISOWithTimeZone :: String -> Effect PlainTimeCurrent time in the given time zone.
examplePlainTimeISOWithTimeZone :: Effect Unit
examplePlainTimeISOWithTimeZone = do
locale <- JS.Intl.Locale.new_ "en-US"
timeUtc <- Now.plainTimeISOWithTimeZone "UTC"
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { timeStyle: "medium" }
Console.log ("Current time (UTC): " <> JS.Intl.DateTimeFormat.format formatter timeUtc)
Current time (UTC): 6:35:28 PM
#timeZoneId Source
timeZoneId :: Effect StringThe system's current time zone identifier (e.g. "America/New_York").
exampleTimeZoneId :: Effect Unit
exampleTimeZoneId = do
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