I have a date-time which I create like this:
Ecto.DateTime.from_erl({{2015, 3, 10}, {0, 0, 0}})
It's a Phoenix app. I want to add days to it with no any additional third-party library. How?
I have a date-time which I create like this:
Ecto.DateTime.from_erl({{2015, 3, 10}, {0, 0, 0}})
It's a Phoenix app. I want to add days to it with no any additional third-party library. How?
You can use erlang's
:calendar
module to manipulate dates without additional dependencies.A standard way of adding days would be to use
:calendar.date_to_gregorian_days/1
do the addition and convert back to the tuple format with:calendar.gregorian_days_to_date/1
.Proper elixir syntax
for datetime let say no_of_days is the number of days u want to add.