# `PgInterop.Interval.Iso8601Formatter`
[🔗](https://github.com/electric-sql/electric/tree/%40core/sync-service%401.6.2/packages/sync-service/lib/pg_interop/interval/iso8601_formatter.ex#L1)

# `format`

Return a human readable string representing the duration, formatted according
to ISO8601. Negative sections will be formatted accordingly, as does PG.

## Examples

    iex> format(Interval.parse!("PT2S"))
    "PT2S"

    iex> format(Interval.parse!("PT2.0001S"))
    "PT2.0001S"

    iex> format(Interval.parse!("PT1M5S"))
    "PT1M5S"

    iex> format(Interval.parse!("PT1M5S"))
    "PT1M5S"

    iex> format(Interval.parse!("P45Y6M5DT21H12M34.590264S"))
    "P45Y6M5DT21H12M34.590264S"

0-length interval is special-cased to render as "0S"

    iex> format(%Interval{months: 0, days: 0, microseconds: 0})
    "PT0S"

---

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