Skip to content

Latest commit

 

History

History
23 lines (19 loc) · 657 Bytes

do-you-have-the-time-part-2.md

File metadata and controls

23 lines (19 loc) · 657 Bytes

Do You Have The Time? - Part 2

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"