How can I get a Unix timestamp in Clojure?


I want to know what the current timestamp is. The best I can do thus far is define my own function that does this:

(int (/ (.getTime (java.util.Date.)) 1000))

Is there a standard function for fetching the Unix timestamp with clojure?

Pretty much all JVM-based timestamp mechanisms measure time as milliseconds since the epoch - so no, nothing standard** that will give seconds since epoch.

Your function can be slightly simplified as:

(quot (System/currentTimeMillis) 1000)

** Joda might have something like this, but pulling in a third-party library for this seems like overkill.