dateToInstant
function dateToInstant(date): Instant;Defined in: datetime-utils.ts:20
Convert a JS Date into a Temporal.Instant.
Prefer this helper over Temporal.Instant.from(date) to avoid relying on
implementation-defined Date parsing/coercion and to get a clearer error
on invalid dates.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
date |
Date |
Returns
Section titled “Returns”Instant
Throws
Section titled “Throws”If date is an invalid Date.
Example
Section titled “Example”const instant = dateToInstant(new Date("2025-01-01T00:00:00Z"));instant.epochMilliseconds; // number