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
You can use
(.getTime (js/Date.))
or you could also use now
or epoch
from cljs-time.
The most efficient way is this
(.now js/Date)
Other answers needlessly create a Date object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With