API Error: Invalid date format — expected ISO 8601 (YYYY-MM-DDTHH:mm:ssZ)
A date or timestamp in the request isn’t in the format the API expects — usually ISO 8601 with a time zone, or a Unix timestamp.
must match format "date-time"must match format "date"Invalid datetimeInput should be a valid datetimeInvalid date format Meaning
Dates are a classic source of 400/422 errors. Locale formats like 03/10/2026 are ambiguous, “2026-10-03 14:00” lacks the T separator and time zone, and some APIs want seconds since epoch while others want milliseconds or an RFC 3339 string.
Validators say things like “must match format "date-time"”, “Invalid datetime”, “Input should be a valid datetime” (Pydantic) or “Cannot deserialize value of type LocalDateTime” (Jackson).
Common causes
- Locale-formatted string (dd/mm/yyyy, mm/dd/yyyy)
- Missing T separator or time zone/offset
- Milliseconds sent where the API expects seconds (or vice versa)
- Date object serialized in a non-standard way
- Invalid offset like +5:30 instead of +05:30
⚡ Quick fix
- Send ISO 8601/RFC 3339 strings in UTC: 2026-10-03T14:00:00Z
- Use toISOString() / isoformat() instead of formatting by hand
- Check whether the API wants seconds or milliseconds
Detailed fix by platform
Node.js
- javascript
const body = { start: new Date(start).toISOString() }; // 2026-10-03T14:00:00.000Z const unix = Math.floor(Date.now() / 1000); // seconds, not ms
Python
- python
from datetime import datetime, timezone datetime.now(timezone.utc).isoformat() # '2026-10-03T14:00:00+00:00'
How to diagnose
- Raw value — Exact string sent
- Docs — ISO string, date-only, seconds or ms?
- Time zone — Present and well-formed?
🔧 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
Most viewed in API
Other ways to find it
Where this error sits
Origin: Application & API. 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 12 Oct 2026