Posted By

ef on 12/21/11


Tagged

date clojure iso8601 clj-time


Versions (?)

Clojure ISO 8601 current date with clj-time


 / Published in: Clojure
 

Better way of generating date in ISO 8601 format (e.g. "2011-12-12T20:50:22+0100"). Needs to require [clj-time.core :as time] and [clj-time.format :as time-format].

  1. (defn- get-current-iso-8601-date
  2. "Returns current ISO 8601 compliant date."
  3. []
  4. (let [current-date-time (time/to-time-zone (time/now) (time/default-time-zone))]
  5. (time-format/unparse
  6. (time-format/with-zone (time-format/formatters :date-time-no-ms)
  7. (.getZone current-date-time))
  8. current-date-time)))

Report this snippet  

You need to login to post a comment.