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

116
Vistas
how do I display an event a day before it happens?

I'm currently building a website for event schedules and such, so basically it displays all the upcoming events and the date of it, and what I want it to do is to sort of highlight the event a day before the actual event happens.

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

let a = new Date(); // today date, will be updated everyday
let b = targetDate; // you need to set this to whichever date you want to check.

a.setDate(a.getDate()+1); // make current date increase by 1;

if(a == b){  // check if target date is equal to today's date + 1
  alert('Today is the day you were waiting for.'); // trigger required event here
}

You can check multiple dates here using for loop.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Look into Luxon. It makes handling these types of problems much eaiser.

But to be more helpful, what you want to do is determine if the date you're comparing is greater than the beginning of tomorrow, and less than the end of tomrrow. There's lots of ways to do this, but the most straight-forward way for a new dev would be something like this in "vanilla" JavaScript:

function isTomorrow(date) {
  var now = new Date();
  var tomorrow = new Date(now.setDate(now.getDate() + 1));
  var startOfTomorrow = tomorrow.setUTCHours(0,0,0,0);
  var endOfTomorrow = tomorrow.setUTCHours(23,59,59,999);
  return Number(date) > startOfTomorrow && Number(date) < endOfTomorrow;
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

    let date = new Date()
    
    date.setDate(date.getDate() - 1)
    
    date;
about 4 years ago · Juan Pablo Isaza Denunciar
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