Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

227
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda