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
| Name | Type | Required | Default |
|---|---|---|---|
date | stringStringstr | ● | – |
Returns
boolean
bool
Examples
javascript
isValidDate('2021-01-01'); // Returns true
isValidDate('2021-02-30'); // Returns falsedart
isValidDate('2021-01-01'); // Returns true
isValidDate('2021-02-30'); // Returns falsepython
isValidDate('2021-01-01') # Returns True
isValidDate('2021-02-30') # Returns False