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

107
Views
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 answers
Answer question

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 Report

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 Report

0

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