Wix ignoring JS logic.

I am scratching my head about this one.

$w.onReady(function () {
    var date = new Date();
    var hours = date.getHours(); //3pm is 15

    if(hours >= 15) {
        $w("#banner").collapse(); // this code runs
    } else {
        console.log('i have NOT collapsed'); // AND this code runs
    }
});

Does Velo / Wix do some kind of preprocessing where it prefers references to $w or something? I’m not new to JS but I am new to Wix.

Have you console.log the hours value? What is the value?

After banging my head on this for hours I think I found the issue. It has nothing to do with my logic and appears to be a bug with the expand/collapse functions in Velo - https://www.wix.com/velo/forum/coding-with-velo/expand-collapse-not-working-on-published-site - and, for anyone else looking, it likely affects show/hide functions also.

expand-collapse work as expected + according to your first post the collapse did work.
and the code you posted is also fine. So the problem is probably somewhere else.
Maybe the time on your computer is not correctly set.
(The code you wrote uses the OS computer time).