Greetings.
I have found some great articles on this topic here but I am having an issue with my timezone and the UTC setting on my Unbounce page.
I want these elements to only show during the PST timezone no matter where the viewer is around the world.
Here is the code I have so far but I can’t get it to work. None of my elements switch no matter what time.
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
var d = new Date();
var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
var nd = new Date(utc + (3600000*offset));
var CurrentDay = nd.getUTCDay();
var BusinessHours = nd.getUTCHours();
console.log(nd);
if (CurrentDay != 0 && CurrentDay < 6 && BusinessHours >= 7 || BusinessHours <= 16) {
$("#lp-pom-box-409").hide();
$("#lp-pom-text-341").hide();
$("#lp-pom-text-461").show();
$("#lp-pom-button-460").show();
$("#lp-pom-button-209").hide();
} else {
$("#lp-pom-box-409").show();
$("#lp-pom-text-341").show();
$("#lp-pom-text-461").hide();
$("#lp-pom-button-460").hide();
$("#lp-pom-button-209").show();
};
</script>
Suggestions? Thanks to everyone who posts here. It has been so helpful but now I am a bit stuck.