RangeError: Invalid time value
A Date is invalid (NaN), and toISOString() or a formatting library couldn’t format it.
Invalid time valueInvalid Date 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 not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 1292 MySQL ERROR 1292 (22007): Incorrect datetime value: 'x' for column 'y'
- 22008 ERROR: date/time field value out of range: "31/12/2024" — HINT: Perhaps you need a different "datestyle" setting.
- DateTimeParseException java.time.format.DateTimeParseException: Text '31/12/2024' could not be parsed at index 2
Most viewed in JavaScript
- TypeError TypeError: Cannot read properties of undefined (reading 'x')
- Failed to fetch TypeError: Failed to fetch / NetworkError when attempting to fetch resource
- module MIME type Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html"
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 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.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 8 Oct 2026