I use Timex library for getting current time. For example:
iex(9)> time = Timex.now
~U[2019-11-29 14:05:39.759000Z]
When I take the minute, I get the following
iex(10)> time.minute
5
If the current minute is up to 10, then I get a value without a leading zero (the same with hours and seconds). I can get the length of the resulting value and, if it's less than 2, add a zero at the beginning, but I think this is not the best solution
Timex
to get the current time in 2019 btw? – Aleksei Matiushkin