Officially, the ISO 8601 spec does not allow for a date with a time zone unless a time is provided. Thus, if you wish to remain ISO 8601 compliant, you cannot provide additional information for date-only values than year, month, and day (without resorting to time intervals - mentioned further below).
One format that does allow for this is XML Schema (aka "XSD"), in the xs:date
type. There, it is optional, and would immediately follow the day, such as 2018-09-07Z
. The XSD spec calls out in Section D.3 Deviations from ISO 8601 Formats:
D.3.4 Time zone permitted
The lexical representations for the
datatypes date, gYearMonth, gMonthDay, gDay, gMonth and gYear permit
an optional trailing time zone specificiation.
I realize you weren't asking about XSD, but this the only normative reference I'm aware of that's freely available online that calls out the time zone on a date is a deviation from ISO 8601.
As others have pointed out - thinking about a date with a time zone is a tricky thing. In many aspects, a date-only value is ambiguous. Consider if I presented you a calendar such as this one:
Pointing at any given date on this calendar doesn't tell me anything about time zones. I can give the calendar to someone in a different time zone and they will still be able to talk about dates. It's simply that if we both point at "today" simultaneously, we might not be pointing at the same date. Thus, time zones only apply when we apply a time context, whether "now" or a specific one.
However, we do tend to rationalize about all points in time on a given day in terms of a time zone. In your example, the "UTC Day". We mean that it runs from T00:00Z
of one day, to just before T00:00Z
of the next. This is generally the reasoning behind things like xs:date
allowing a time zone offset.
If we wanted to be strictly ISO 8601 compliant and represent the same meaning, we'd have to provide a range of date+time values, which are called "time intervals" in section 4.4 of the ISO 8601 spec, and are separated with a forward slash (/
) character. An example of such a value would be 2018-09-07T00:00Z/2018-09-08T00:00Z
. However, be careful because ISO 8601 says nothing about whether the end date should be interpreted inclusively or exclusively. More on that here.
Another ISO 8601 representation of an interval allows for a start time and a duration component, such as 2018-09-07T00:00Z/P1D
. This feels to me like the closest fully ISO 8601 compliant way to represent a whole date interpreted in UTC.
Still, personally, if I needed to convey time zone with a date, I would use 2018-09-07Z
even if it wasn't strictly compliant. Just make sure all consumers of your data agree on this format. If you can't do that, just pass 2018-09-07
and name your field something like utcDate
.
2011-12-03+01:00
or2018-09-07Z
(noT
) has been seen, see for example here. What do you need it for? If you have a good use case and the relevant parties agree, I think I’d go for it and not be too worried whether it conforms with ISO 8601 or not.ISO_OFFSET_DATE
formatter. Quote: “The ISO date formatter that formats or parses a date with an offset, such as '2011-12-03+01:00'. This returns an immutable formatter capable of formatting and parsing the ISO-8601 extended offset date format.” So they seem to think that it does agree with ISO 8601. Whether they misread the sources or you did I dare not tell.