NaiveDateTime.to_iso8601

You're seeing just the function to_iso8601, go back to NaiveDateTime module for more information.
Link to this function

to_iso8601(naive_datetime, format \\ :extended)

View Source

Specs

to_iso8601(Calendar.naive_datetime(), :basic | :extended) :: String.t()

Converts the given naive datetime to ISO 8601:2019.

By default, NaiveDateTime.to_iso8601/2 returns naive datetimes formatted in the "extended" format, for human readability. It also supports the "basic" format through passing the :basic option.

Only supports converting naive datetimes which are in the ISO calendar, attempting to convert naive datetimes from other calendars will raise.

Examples

iex> NaiveDateTime.to_iso8601(~N[2000-02-28 23:00:13])
"2000-02-28T23:00:13"

iex> NaiveDateTime.to_iso8601(~N[2000-02-28 23:00:13.001])
"2000-02-28T23:00:13.001"

iex> NaiveDateTime.to_iso8601(~N[2000-02-28 23:00:13.001], :basic)
"20000228T230013.001"

This function can also be used to convert a DateTime to ISO 8601 without the time zone information:

iex> dt = %DateTime{year: 2000, month: 2, day: 29, zone_abbr: "CET",
...>                hour: 23, minute: 0, second: 7, microsecond: {0, 0},
...>                utc_offset: 3600, std_offset: 0, time_zone: "Europe/Warsaw"}
iex> NaiveDateTime.to_iso8601(dt)
"2000-02-29T23:00:07"