Answers for "how to check if month is same of two date in js"

0

get month in two digit in javascript date

("0" + (this.getMonth() + 1)).slice(-2)
Posted by: Guest on May-18-2020
0

check if the difference between two dates is more than 1 month in javascript

const diffInMonths = (end, start) => {
   var timeDiff = Math.abs(end.getTime() - start.getTime());
   return Math.round(timeDiff / (2e3 * 3600 * 365.25));
}

const result = diffInMonths(new Date(2015, 3, 28), new Date(2015, 1, 25));

// shows month difference as integer/number
console.log(result);
Posted by: Guest on August-11-2021

Code answers related to "how to check if month is same of two date in js"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language