Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add days to current date

Am new to clojure, can anyone help me to understand how can I get current date in clojure and then adding days to it? for e.g. adding 3 days to current date?

like image 858
Robin Avatar asked Nov 25 '14 04:11

Robin


People also ask

How do you add the number of days to today's date?

Using the DATE(year, month, day) function, e.g. =DATE(2015, 5, 6) + 10. As a result of another function. For example, to add a given number of days to the current date, use the TODAY() function: =TODAY()+10.

How do I add 30 days to a date in Excel?

In cell C1, type =A1+30, and then press RETURN . This formula adds 30 days to the date in cell A1.

How many days add to a year?

The mean length of its year is 365.25 days. To make it dividable into days we accept that three years in a row will have 365 days and the forth one, also called leap year, will have 366 days with one more day added to February. This is the calendar used in our calculator.


1 Answers

The idiomatic Clojure way is to use clj-time (see link for Leiningen/Maven install instructions), which wraps Joda time as referenced by the first answer from overthink.

user=> (use '[clj-time.core])
nil
user=> (now)
#<DateTime 2014-11-25T12:03:34.714Z>
user=> (plus (now) (days 3))
#<DateTime 2014-11-28T12:05:40.888Z>
like image 188
Matt Innes Avatar answered Oct 25 '22 20:10

Matt Innes