Tutorial by Examples

(clj-time/date-time 2017 1 20) Gives you a Joda time of 20th Jan 2017 at 00:00:00. Hours, minutes and seconds can also be specified as (clj-time/date-time year month date hour minute second millisecond)
(require '[clj-time.core :as t]) (def example-time (t/date-time 2016 12 5 4 3 27 456)) (t/year example-time) ;; 2016 (t/month example-time) ;; 12 (t/day example-time) ;; 5 (t/hour example-time) ;; 4 (t/minute example-time) ;; 3 (t/second example-time) ;; 27
(require '[clj-time.core :as t]) (def date1 (t/date-time 2016 12 5)) (def date2 (t/date-time 2016 12 6)) (t/equal? date1 date2) ;; false (t/equal? date1 date1) ;; true (t/before? date1 date2) ;; true (t/before? date2 date1) ;; false (t/after? date1 date2) ;; false (t/after? date2 dat...
This function tells whether a given time lies within a a given time interval. (require '[clj-time.core :as t]) (def date1 (t/date-time 2016 11 5)) (def date2 (t/date-time 2016 12 5)) (def test-date1 (t/date-time 2016 12 20)) (def test-date2 (t/date-time 2016 11 15)) (t/within? (t/interva...
The clj-time.coerce library can help converting other date-time formats to joda time format (clj-time.core/date-time). The other formats include Java long format, String, Date, SQL Date. To convert time from other time formats, include the library and use the from- function, e.g. (require '[clj-ti...
cljs-time gives us option to add/subtract date-times to other date-times. The date times added subtracted should be in form of days, months, years, hours etc. (require '[clj-time.core :as t]) (def example-date (t/date-time 2016 1 1)) ;; #<DateTime 2016-01-01T00:00:00.000Z> ;; Addition ...

Page 1 of 1