Skip to content

isValidDate

Checks if a given date actually exists. Check only in YYYY-MM-DD format.

Supported years are 1600-9999, plus two-digit years 16-99. Any other year returns falseFalse. Note that an input that is not in YYYY-MM-DD format throws rather than returning falseFalse.

The date can be checked only from 1600-01-01 to 9999-12-31 and all dates before 1600 are returned as falseFalse.

Parameters

NameTypeRequiredDefault
datestringStringstr

Returns

boolean

bool

Examples

javascript
isValidDate('2021-01-01'); // Returns true
isValidDate('2021-02-30'); // Returns false
dart
isValidDate('2021-01-01'); // Returns true
isValidDate('2021-02-30'); // Returns false
python
isValidDate('2021-01-01')  # Returns True
isValidDate('2021-02-30')  # Returns False

Released under the MIT License