Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda