I have two date pickers that calculates the number of days there are between the two dates. At the moment I\'m outputting the number of days (see code below) which is kind o
When you want to get the year and month between two date:
var dateFrom = '2017-08-10';
var dateTo ='2019-04-23';
var date1 = new Date(dateFrom);
var date2 = new Date(dateTo);
var diff=0;
var month=31;
var days=1000*60*60*24;
diff=date2-date1;
var day=(Math.floor(diff/days));
var years = (Math.floor(day/365));
var months = Math.round(day % 365)/month;
document.write(years+"year-"+months);