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

160
Views
The method isBefore from momentjs does not work

I want to check if one of the date is before taking into account the minute;

// 1610459035000 Tuesday, 12 January 2021 13:43:55
// 1642081435000 Thursday, 13 January 2022 13:43:55
const a = moment(1610459035000).isBefore(1642081435000, 'minute');
console.log(a) //get true but expect false
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>

Making console.log(a) i expect to get false because the minutes are the same in both cases even if the years are difefrent.
Why i get true if minutes are the same?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

See the docs.

The second argument limits precision.

This means that if your dates were 2001-01-01T00:00:10 and 2001-01-01T00:00:05 then normally the one that is five seconds after midnight would be before the one that is 10 seconds after midnight. If you specify 'minute' precision then it would ignore the difference in seconds and treat them as the same time.

On the other hand, 2001-01-01T00:00:00 and 2002-01-01T00:00:00 are different years. If you have minute precision then the seconds are ignored but one is still clearly before the other.

Only the parts of the values that are smaller then the specified level are ignored, not the parts that are larger.

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!