Search code examples
clojurescript

How do you get a timestamp in ClojureScript?


How can I get a timestamp in ClojureScript, similar to Unix's timestamp, a single number that represents the current time and date, as a number. I know that:

if (!Date.now) {
    Date.now = function() { return new Date().getTime(); }
}

can be used in Javascript but I want to know if there is a ClojureScript equivalant


Solution

  • You can use

    (.getTime (js/Date.))
    

    or you could also use now or epoch from cljs-time.