Elixir DateTime now in seconds
I just found out that since elixir 1.15.0 we can call DateTime utc now and get that response truncated in seconds already:
iex> DateTime.utc_now(:second)
~U[2025-06-03 13:27:44Z]
and this has the same effect of what I used to do until now:
iex> DateTime.utc_now() |> DateTime.truncate(:second)
~U[2025-06-03 13:27:45Z]
Tweet