I am trying to get months counts with two days like if i have two months with current date so i need a count of 2 like
var todaydate='20/06/2018';
var dynamicdate='05/08/2018';
i need months difference with this format can anyone help on this?
I am trying to get months counts with two days like if i have two months with current date so i need a count of 2 like
var todaydate='20/06/2018';
var dynamicdate='05/08/2018';
i need months difference with this format can anyone help on this?
Convert strings to Date object and use getMonth() method
var month1 = (new Date("2018-06-20")).getMonth();
var month2 = (new Date("2018-08-05")).getMonth();
var months = Math.abs(month2 - month1);
alert(months);
Or, even simpler:
var months = Math.abs(0 + todaydate.split('/')[1] - dynamicdate.split('/')[1]);
alert (months);