R
fn

normalizeDate

testeddemo

Coerce a {@link DateLike} into a `Date`. `null`/`undefined` become the current time; a non-UTC string is parsed leniently so partial dates such as `'2024-3'` are accepted.

Demo

Loading demo…

Signature

ts
export function normalizeDate(date: DateLike): Date{ ... }

Parameters

ParameterTypeDescription
dateDateLikeThe value to coerce

Returns

DateA `Date` instance (possibly `Invalid Date`)