XSD datatype
xs:dateTime
A date and time in ISO 8601 form, requiring the T separator and zero-padding. Timezone is optional, which causes more trouble than it saves.
The lexical form is YYYY-MM-DDThh:mm:ss, with an optional fractional second and an optional timezone of Z or ±hh:mm. Every component is zero-padded to its full width — '2026-1-1' is not a date.
The timezone being optional is the design flaw you inherit. A dateTime with no timezone has no defined instant, so two systems can disagree about what it means and both be conforming. Require Z in your own schemas with a pattern facet.
- Lexical space
- YYYY-MM-DDThh:mm:ss with optional .fraction and optional Z or ±hh:mm.
- Derives from
- Primitive type
- Category
- Date and time types
- Facets
- minInclusive, maxInclusive, minExclusive, maxExclusive, pattern, enumeration, whiteSpace
What validates
Every literal below is put through the schema validator on each test run, against the schema at the foot of this page.
2026-08-18T09:14:22Z2026-08-18T09:14:222026-08-18T09:14:22.123Z2026-08-18T09:14:22+02:00-0044-03-15T12:00:00Z
What does not
2026-8-18T09:14:22ZMonths must be zero-padded to two digits.
2026-08-18 09:14:22ZThe date and time are separated by T, not a space.
2026-08-18T09:14:22ESTTimezones are Z or a numeric offset, never an abbreviation.
2026-02-30T00:00:00ZFebruary has no 30th — dates are checked for real.
2026-08-18A dateTime requires the time part.
What catches people out
- A space instead of T is the most common failure, because that is how most databases print a timestamp.
- Without a timezone the value has no defined instant. Two conforming systems can read it differently.
- Real calendar rules apply: 2026-02-30 fails, and 2024-02-29 passes because 2024 is a leap year.
- Seconds are mandatory. '2026-08-18T09:14Z' is not a valid dateTime.
The schema used
This is the exact schema the literals above are validated against. Paste it into the validator with one of them to see the result yourself.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="v" type="xs:dateTime"/>
</xs:schema>Related
- xs:dateA calendar date, zero-padded, with an optional timezone that almost nobody expects it to have.
- xs:timeA time of day, seconds mandatory, with 24:00:00 legal and 24:00:01 not.
- xs:durationA length of time in ISO 8601 form, starting with P — and only partially ordered, because months have no fixed length.
- patternA regular expression the whole value must match — anchored implicitly, and in XSD's own dialect rather than PCRE.
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.