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

150
Views
Obtener un 'No es un error de función' al calcular los meses con Moment JS

Aquí está mi violín http://jsfiddle.net/p1kr0ayj/2/

 function letsGo() { //for the inputs let name = document.querySelector('#inputName').value; let date = document.querySelector('#inputDate').value; let welcm = document.getElementById("welcome").innerHTML; let errorpopup = document.getElementById("error"); let animation = document.getElementsByClassName("anim")[0]; let currDate = moment().format("MM-DD-YYYY"); console.log(currDate); let getDate = moment(date, "MM-DD-YYYY"); if (getDate.isValid()) { //for the name welcm = "Welcome " + name; //calculating years yr = currDate.diff(getDate, 'years'); //heres the error getDate.add(yr, 'years'); //calculating motnhs month = currDate.diff(getDate, 'months'); getDate.add(month, 'months'); console.log("nays", yr, month, currDate); } else { errorpopup.innerHTML = "Check Date"; animation.classList.add('animError'); } //console.log(getDate, errorpopup); }

Mi objetivo aquí es obtener la diferencia total del mes, no el total de meses desde el año ingresado. como la respuesta en la siguiente pregunta.

Traté de seguir lo que está en la documentación y todavía no se trata de un error de función.

Traté de seguir esta Pregunta Moment.js - Obtenga la diferencia en dos cumpleaños en años, meses y días

Todavía recibe el error.

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!