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

249
Views
¿Por qué esto produce NaN?

Cuando pruebo esto, produce NaN

 const date1 = new Date('29/11/2021'); const date2 = new Date('30/11/2021'); const diffTime = Math.abs(date2 - date1);

pero esto funciona

 const date1 = new Date('7/13/2010'); const date2 = new Date('12/15/2010'); const diffTime = Math.abs(date2 - date1);

¿Podría alguien explicar por qué?

Recibí el código de esta pregunta pero cuando lo probé con mis fechas no funcionó

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

0

En realidad, producir NaN depende del navegador. Algunos navegadores podrían interpretar la nueva fecha ('29/11/2021') como 29 meses = 12+12+5 => 11 de mayo de 2023

Para estar seguro de que podría usar más fácil de analizar

 new Date('November 29, 2021');

o incluso

 new Date(2021, 10, 29); // its important, that in such constructor form months start from 0
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!