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

334
Views
How is the difference between these two momentjs dates 0?

I have a function that is looking to determine if a date is in the past. It uses moment to take the difference between these two dates. However when the given date is tomorrow the difference is 0 when I'd expect for it to be 1.

const isPastDate = (date) => {
  if (date) {
    console.log(date);

    const givenDate = moment(date);
    const today = moment();

    console.log("givenDate => ", givenDate);
    console.log("today => ", today);
    const diff = today.diff(givenDate, "days");

    console.log("diff => ", diff);
    const result = diff >= 0;
    return result;
  }
};

enter image description here

about 4 years ago · Juan Pablo Isaza
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!