I am trying to get a datetime which has only 3 digits in the sub-second part.
Using timex I get the following result:
iex(12)> {:ok, date} = Timex.format(Timex.shift(Timex.local, days: 16), "{ISO:Extended}")
{:ok, "2017-04-22T09:00:44.403879+03:00"}
How can I get something like this:
{:ok, "2017-04-22T09:00:44.403+03:00"} ?
DateTimehas amicrosecondfield which is a tuple containing the value and precision. If you change the precision to3, you'll get 3 digits in the microsecond output. I couldn't find any function in Timex which does this, but you can modify the value manually: