In Do You Have The
Time?,
I demonstrated a way of using an Erlang function to get at and work with
time in Elixir. As of Elixir 1.3, there is now a Time
module that provides a
sigil and some functions for working with time.
We can use Elixir's Time
module to simplify the example from the previous
iteration of this TIL:
defmodule TickTock do
def current_time do
Time.from_erl!(:erlang.time)
|> Time.to_string
end
end
> TickTock.current_time
"19:58:12"