I am stuck getting this script to show certain elements during the week from 7 am to 4 pm PST and outside of that show a different element off hours and on the weekends.
I created this script but my hours are not working right. The script does not automatically start at 7 AM and automatically end at 4 PM even though I manually enter my UTC offset for Los Angeles.
The elements I am trying to show are from Unbounce so it might look a bit unfamiliar.
If anyone has any suggestions getting the hours to work correctly no matter what timezone someone in, I would really appreciate it? Thank you.
var d = new Date();
var localTime = d.getTime();
var localOffset = d.getTimezoneOffset() * 60000;
var utc = localTime + localOffset;
var offset = -7
var PST = utc + (3600000*offset);
var nd = new Date(PST);
var CurrentDay = nd.getDay();
var BusinessHours = nd.getHours();
if (CurrentDay !== 0 || CurrentDay !== 6) {
if (BusinessHours >= 16 || BusinessHours <= 7 ) {
$("#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();
}
}