Skip to content

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.

Parameter Type
date Date

Instant

If date is an invalid Date.

const instant = dateToInstant(new Date("2025-01-01T00:00:00Z"));
instant.epochMilliseconds; // number