Get yesterday's date in Clojure -
i need yesterday's date (not user-based, relative server) in format yyyy-mm-dd
.
what best way achieve in clojure?
with java 8 time api:
(import (java.time localdate) (java.time.format datetimeformatter)) (def formatter (datetimeformatter/ofpattern "yyyy-mm-dd")) (def yesterday (.minusdays (localdate/now) 1)) (.format formatter yesterday) ;; => "2017-04-05"
or java 8 time api clojure wrapper: clojure.java-time
(require '[java-time :as t]) (def yesterday (t/minus (t/local-date) (t/days 1))) (t/format "yyyy-mm-dd" yesterday) ;; => "2017-04-05"
Comments
Post a Comment