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

111
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

0

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