Get to know MDN better
The JavaScript exception "invalid date" occurs when an invalid date is attempted to be converted to an ISO date string.
You are converting an invalid date value to an ISO date string. This usually happens in one of three ways:
An invalid date is produced when you attempt to parse an invalid date string, or set the timestamp to an out-of-bounds value. Invalid dates usually cause all date methods to return NaN or other special values. However, such dates do not have valid ISO string representations, so an error is thrown when you attempt to do so.
However, most other methods return special values:
For more details, see the Date.parse() documentation.
This page was last modified on Jul 8, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.