NaiveDateTime.diff

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

diff(naive_datetime1, naive_datetime2, unit \\ :second)

View Source (since 1.4.0)

Specs

Subtracts naive_datetime2 from naive_datetime1.

The answer can be returned in any unit available from System.time_unit/0.

This function returns the difference in seconds where seconds are measured according to Calendar.ISO.

Examples

iex> NaiveDateTime.diff(~N[2014-10-02 00:29:12], ~N[2014-10-02 00:29:10])
2
iex> NaiveDateTime.diff(~N[2014-10-02 00:29:12], ~N[2014-10-02 00:29:10], :microsecond)
2_000_000
iex> NaiveDateTime.diff(~N[2014-10-02 00:29:10.042], ~N[2014-10-02 00:29:10.021], :millisecond)
21
iex> NaiveDateTime.diff(~N[2014-10-02 00:29:10], ~N[2014-10-02 00:29:12])
-2
iex> NaiveDateTime.diff(~N[-0001-10-02 00:29:10], ~N[-0001-10-02 00:29:12])
-2

# to Gregorian seconds
iex> NaiveDateTime.diff(~N[2014-10-02 00:29:10], ~N[0000-01-01 00:00:00])
63579428950