In Elixir, we often need to set milliseconds. This is especially common when working with GenServer, Task.Supervisor, Agent and others.
While we could write our milliseconds directly:
Did you know that was 3 hours just by glancing at it? Sure the math is fairly easy, but why make us think? Erlang’s timer to the rescue!
iex()> :timer.hours(3) 10800000
Well that makes our 3 hours pretty legible if you ask me.
We also have minutes and seconds:
iex()> :timer.minutes(11) 660000 iex()> :timer.seconds(455) 455000