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

148
Views
Dayjs y los objetos de fecha simple dan una diferencia diferente

En este enlace de la biblioteca de Dayjs leerás esto:

 const date1 = dayjs('2019-01-25') const date2 = dayjs('2018-06-05') date1.diff(date2) // 20214000000 default milliseconds

Pero si escribes en la consola, obtendrás esto:

 new Date(2019,0,25) - new Date(2018,5,5) // result: 20221200000

¿Por qué la diferencia?

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

0

const dayjs = require("dayjs") const date1 = dayjs("2019-01-25") const date2 = dayjs("2018-06-05") console.log(date1.diff(date2)) // 20214000000 console.log(new Date(2019, 0, 25) - new Date(2018, 5, 5)) // 20214000000 console.log(new Date(2019, 0, 25).getTime() - new Date(2018, 5, 5).getTime()) // 20214000000

Puede obtener la marca de tiempo de Date con la función .getTime() , y en este caso solo está haciendo 1548381600000 - 1528167600000 . No estoy seguro de cómo 20221200000 pero este valor es simplemente incorrecto.

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!