"Invalid Date" in JavaScript — What It Means and How to Fix It
What the JavaScript error "Invalid Date" means and how to fix it.
Published October 30, 2026
'Invalid Date' is what new Date(...) produces when it cannot parse its input. Operations on it return NaN.
What it means and why it happens
Typical causes: unsupported date strings, wrong formats (DD/MM/YYYY), missing values or timezone parsing differences.
Read the full message: it names the file and line where the problem was detected, which is the best place to start.
What you see
run the code
Invalid Date
Practical examples
Code that triggers it
new Date('31/12/2026')The fix
new Date('2026-12-31') // ISO format is safest
new Date(Date.UTC(2026, 11, 31))Check validity
const d = new Date(input)
if (Number.isNaN(d.getTime())) throw new Error('Invalid date')Common mistakes
- Parsing locale formats.
- Using month index 1-12 (months are 0-11).
- Ignoring time zones.
Key takeaways
- Invalid Date: 'Invalid Date' is what new Date(...) produces when it cannot parse its input.
- Read the message and the line number first.
- Fix the cause, don't just silence the error.
FAQ
Safe format?
ISO 8601: YYYY-MM-DDTHH:mm:ssZ.
How do I find which line caused Invalid Date?
The error message and stack trace show the file and line; start there and work backwards.