Clojure ISO 8601 current date with clj-time


/ Published in: Clojure
Save to your folder(s)

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].


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.