Skip to content

toDate()

function toDate(value): Date | null;

Converts a value to a Date. Accepts Date objects, epoch milliseconds and date strings. Date-only ISO strings (“2026-03-01”) are read as local midnight, not UTC, so they do not shift by a day in western time zones. Returns null when the value is not a valid date.

Parameter Type
value unknown

Date | null