Getting the current date and or time in Elixir

This seems like a really dumb question but how does one get and display the current date or time in Elixir? I tried going through the docs but couldn't find anything. Do I need to use an Erlang function?


You can use DateTime.utc_now/0 to get UTC DateTime.


To answer your question more specifically (though I really appreciate Onorio's recommendation to use Timex!), you can get the current date and time from the Erlang standard lib using :calendar.universal_time() or :calendar.local_time(). There are a number of useful functions for working with Erlang's datetime type in the calendar module, but they are somewhat limited, and don't provide you with anything for parsing or formatting dates, which is where Timex comes in.