Variance between `(js/Date.)` in my app and in the shadow-cljs REPL

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,
Raphael

I tried in REPL:

> (println (js/Date.))
#inst "2020-11-19T06:52:42.576-00:00"
nil
> (js/console.log (js/Date.))
nil

it displays in Chrome:

#inst "2020-11-19T06:52:42.576-00:00"
Thu Nov 19 2020 14:53:39 GMT+0800 (China Standard Time)

appears that println formats time internally so it’s UTC time.

First thing to point out is that the dates aren’t different, it’s just how they’re printing. Dates have no zone info. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

The default print for the browser is local wall clock, and shadow repl is utc

2 Likes

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.