Middle
What date formats are used in JSON Schema in practice?
sobes.tech AI
Answer from AI
In JSON Schema, standard formats based on ISO 8601 are usually used to describe date and time formats. In practice, the most common values for the format property for dates are:
date— date in the format YYYY-MM-DD, for example, "2024-06-15".date-time— date and time in ISO 8601 format with timezone, for example, "2024-06-15T13:45:30Z" or "2024-06-15T13:45:30+03:00".
These formats allow validating strings as correct dates or date-times. Other formats, such as time (time only), are less common.
Example of usage in JSON Schema:
{
"type": "string",
"format": "date-time"
}
This guarantees that the value will conform to the ISO 8601 standard for date and time.