I’m asking in the beginners’ section in case this is quite obvious to most of you. When I invoke
(js/Date.) in the REPL (I am using shadow-cljs) I get today’s date according to Universal Control Time, and when I do so in my app I get today’s date according to my local timezone.
Anyone care to offer an explanation as to why this is so?
Thank you for reading,
I tried in REPL:
> (println (js/Date.))
> (js/console.log (js/Date.))
it displays in Chrome:
Thu Nov 19 2020 14:53:39 GMT+0800 (China Standard Time)
println formats time internally so it’s UTC time.
The default print for the browser is local wall clock, and shadow repl is utc
Thank you for this great way easily to demonstrate the variance between ‘REPL-time’ and ‘Broswer-time’ which I was pointing out.
Thanks for that clue, that it’s simply their output which is set either to the local time zone or to UTC.
Curious if it’s possible to set shadow’s time zone to local time instead of UTC.
When looking at it on the browser console or just calling
.toString you get the default representation the browser choses which is in your local timezone.
There is no such thing as REPL-time or Browser-time. They are the exact same times just printed differently. You cannot modify the REPL representation but if it bothers you can use
(.toLocaleString the-date) or
(.toString the-date) instead.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.