# `Spectral.Codec.DateTime`
[🔗](https://github.com/andreashasse/spectral/blob/main/lib/spectral/codec/date_time.ex#L1)

Built-in codec for `DateTime.t()`.

Encodes `DateTime` structs to ISO 8601 / RFC 3339 strings
(e.g. `"2012-04-23T18:25:43.511Z"`) and decodes them back.
Handles `:json` and `:binary_string` formats (returning a binary string) and
`:string` format (returning a charlist).

## Registration

Registered automatically when the `:spectral` application starts. To use a
different codec for `DateTime.t()`, set it in `config :spectra, :codecs`;
user-configured codecs take precedence over the built-ins.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
