Skip to content

isValidDate ​

The isValidDate function checks if a value is a valid JavaScript date.

Syntax ​

typescript
isValidDate(value: any): boolean;

Parameters ​

NameTypeDescription
valueanyValue to be checked

Returns ​

TypeDescription
booleanTrue if the value is a valid date

Examples ​

typescript
isValidDate(new Date());
// => true

isValidDate("2024-06-10");
// => true

isValidDate("invalid date");
// => false

Notes ​

  • Useful for input validation before performing date operations.

References ​

Released under the MIT License.