ToDate
cartographer / toDate
Function: toDate()
Section titled “Function: toDate()”toDate(
value):Date|null
Defined in: types/types.ts:32
Safely convert a value to a Date. Returns the Date if possible, otherwise returns null.
Parameters
Section titled “Parameters”unknown
Any value that might be a date
Returns
Section titled “Returns”Date | null
- Date object if conversion succeeds, null otherwise
Example
Section titled “Example”const date1 = toDate('2026-01-06'); // Returns: Date objectconst date2 = toDate(1704844800000); // Returns: Date object (timestamp)const date3 = toDate('invalid'); // Returns: null