> For the complete documentation index, see [llms.txt](https://docs.internetobject.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.internetobject.org/schema-definition-language/data-types/date-and-time.md).

# Date and Time

Internet Object has three temporal types, each with its own literal value:

| Type       | Literal                    | Captures               |
| ---------- | -------------------------- | ---------------------- |
| `date`     | `d'2024-03-20'`            | calendar date          |
| `time`     | `t'14:30:45'`              | time of day            |
| `datetime` | `dt'2024-03-20T14:30:45Z'` | date + time (ISO 8601) |

> For the literal value syntax in detail, see [Date and Time](/structure-and-syntax/values/date-and-time.md).

```ruby
created: datetime, birthday: date, opensAt: time
---
~ dt'2024-03-20T14:30:00Z', d'1990-05-01', t'09:00:00'   # ✓
```

## TypeDef

These types share one TypeDef. A MemberDef accepts only the options below.

| Option     | Type     | Description                                                  |
| ---------- | -------- | ------------------------------------------------------------ |
| `type`     | string   | `datetime`, `date`, or `time`. First positional value.       |
| `default`  | datetime | Value used when the member is omitted.                       |
| `choices`  | array    | Restricts the value to a fixed set.                          |
| `min`      | datetime | Earliest allowed value (inclusive).                          |
| `max`      | datetime | Latest allowed value (inclusive).                            |
| `optional` | bool     | If `true`, the member may be omitted. Shorthand: `?` suffix. |
| `null`     | bool     | If `true`, the member may be `null`. Shorthand: `*` suffix.  |

There is deliberately **no `format` option**. For the numeric and string types a `format` selects a spelling for one unchanging value, but a date is not a datetime — the three temporal types are genuinely different, so the choice lives in the **type name**, which both constrains the value and selects its literal. See [Constraints and presentation](/schema-definition-language/advanced-schema-concepts/memberdef.md#constraints-and-presentation).

A writer therefore emits the literal matching the declared type: `date` → `d"…"`, `time` → `t"…"`, `datetime` → `dt"…"`. Where no schema applies, the kind is inferred from the value instead — see [Temporal kind](/serialization/value-formatting.md#temporal-kind).

## Constraints

### min / max

```ruby
when: { datetime, min: dt'2024-01-01T00:00:00Z', max: dt'2024-12-31T00:00:00Z' }
---
~ dt'2024-06-01T00:00:00Z'    # ✓
```

## Optional, nullable & defaults

```ruby
deletedAt?*: datetime   # optional + nullable
---
~ {}    # ✓ omitted → absent
~ N     # ✓ null
```

| Input                   | Result                   |
| ----------------------- | ------------------------ |
| valid temporal literal  | the value                |
| out of `min`/`max`      | `invalid-range` error    |
| `N`, nullable (`*`)     | `null`                   |
| `N`, not nullable       | `null-not-allowed` error |
| omitted, optional (`?`) | absent                   |
| omitted, required       | `value-required` error   |

## See Also

* [Date and Time (value syntax)](/structure-and-syntax/values/date-and-time.md)
* [TypeDef](/schema-definition-language/advanced-schema-concepts/typedef.md) · [MemberDef](/schema-definition-language/advanced-schema-concepts/memberdef.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.internetobject.org/schema-definition-language/data-types/date-and-time.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
