Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #check #difference #dates #month #javascript
ADD COMMENT
Topic
Name
9+2 =