RangeError: Invalid time value
A Date is invalid (NaN), and toISOString() or a formatting library couldn’t format it.
Seen on:
JavaScript
Meaning
new Date(string) returns Invalid Date for unparseable strings; toISOString() then throws. Locale strings like "31/12/2024" aren’t parsed by Date.
Common causes
- Unparseable date string
- Undefined/null date
- Non-ISO formats (DD/MM/YYYY)
- date-fns/Intl given an invalid date
⚡ Quick fix
- Validate: isNaN(date.getTime())
- Use ISO 8601 strings (2024-12-31)
- Parse custom formats explicitly
Detailed fix by platform
JavaScript
- javascript
const d = new Date(value); if (Number.isNaN(d.getTime())) throw new Error('Bad date: ' + value);
How to diagnose
- Input — What string/number produced the date?
- Recent change — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026