isValid

Commons
stable

Returns true when the given value can be coerced into a valid JavaScript Date (not NaN). Accepts any input type.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

date
required
any
The value to test. Can be a Date object, a date string, a timestamp number, or any other value.

API

Return value

The value returned by this util.

true when the value produces a valid Date (not NaN), false otherwise.

Usage

Examples

Ready-to-paste usage snippets.

Valid and invalid date inputs

typescript