Today I Learned

hashrocket A Hashrocket project

Create A Date With The Date Sigil

Elixir 1.3 introduced a new sigil for creating dates, ~D. It works in the same way as Date's new/3 function producing the Date struct with each of the date parts.

> ~D[2016-01-01]
~D[2016-01-01]
> ~D[2016-01-01].year
2016
> ~D[2016-01-01].month
1
> ~D[2016-01-01].day
1
See More #elixir TILs
Looking for help? At Hashrocket, we 💜 Elixir! From our many Elixir client projects, to sponsoring the Chicago Elixir Meetup, to the source code for this application, we are invested in this community. Contact us today to talk about your Elixir project.