I need to get data difference like years, month, date etc. like wise. this is my code
time1 =new Date(1988, 1, 8, 23, 23, 0, 0);
time2 = new Date();
difference = time2 - time1;
document.write(difference);
this returns something like this 782215145373
. I think milliseconds. so how I get that difference like years, months, days, hours, minutes, seconds, milliseconds wise.
Actually in here I tried this way to get month difference
month_diff = time2.getMonth()-time1.getMonth();
but it gives 9 but correct answer should be 10. please help me why?