invalid time value JavaScript Origin: On your device OSI layer 7 · Application Last updated 8 Oct 2026

RangeError: Invalid time value

A Date is invalid (NaN), and toISOString() or a formatting library couldn’t format it.

Exact message you may see Invalid time valueInvalid Date
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

  1. Validate: isNaN(date.getTime())
  2. Use ISO 8601 strings (2024-12-31)
  3. Parse custom formats explicitly

Detailed fix by platform

JavaScript

  1. javascript
    const d = new Date(value);
    if (Number.isNaN(d.getTime())) throw new Error('Bad date: ' + value);

How to diagnose

  1. Input — What string/number produced the date?
  2. 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:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

1292 — MySQL ERROR 1292 (22007): Incorrect datetime value: 'x' for column 'y' (MySQL)129222008 — ERROR: date/time field value out of range: "31/12/2024" — HINT: Perhaps you need a different "datestyle" setting. (PostgreSQL)22008DateTimeParseException — java.time.format.DateTimeParseException: Text '31/12/2024' could not be parsed at index 2 (Java)DateTimeParseExceptionInput string was not in a correct format — System.FormatException: Input string was not in a correct format (.NET)Input string was not …InputMismatchException — java.util.InputMismatchException (Scanner) (Java)InputMismatchExceptioninvalid_date — API Error: Invalid date format — expected ISO 8601 (YYYY-MM-DDTHH:mm:ssZ) (API)invalid_dateNumberFormatException — java.lang.NumberFormatException: For input string: "x" (Java)NumberFormatExceptionUnparseable date — java.text.ParseException: Unparseable date: "x" (Java)Unparseable dateinvalid t…

Explore the map of this error Full error map →

🧠 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.