Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
Javascript time script does not automatically switch when needed

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();

   }
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!