+ 1

Update :- trying to calculate months between two dates in javascript? pls check the following js file. Also please remember

var userdateObj1 = new Date(userdate1); var userdateObj2 = new Date(userdate2); // window.alert ("userdateObj is: "+userdateObj); var msPerDay = 24 * 60 * 60 * 1000; var userdateObjmSeconds1 = userdateObj1.getTime(); var userdateObjmSeconds2 = userdateObj2.getTime(); var totalmonthsleft; var totaldaysLeft; if (userdateObjmSeconds1 < userdateObjmSeconds2){ totaldaysLeft = Math.ro

13th Mar 2018, 9:55 AM
A Google User
A Google User - avatar
4 odpowiedzi
+ 4
With your code, you miss the monthes between the two date. For me, you have to code : DateTo.getMonth() - DateFrom.getMonth() + (12 * (DateTo.getFullYear() - DateFrom.getFullYear())); You will perhaps also add 1 if you include or not the From month.
12th Mar 2018, 2:12 PM
Geo
Geo - avatar
0
If you mind speed over accuracy, here's a code that gets the number of months with less than 3 day error for dates less than 100 years apart Edit: added a second ratio ("ratioover100") which is more accurate for the long times, but may give worse accuracy in short ones. https://code.sololearn.com/WRIE9AEGh4If/?ref=app
12th Mar 2018, 2:24 PM
spcan
spcan - avatar
0
GUYS PLEEASE CHECK AND TELL ME HOW TO get on with it
13th Mar 2018, 9:55 AM
A Google User
A Google User - avatar
0
[SOLVED]
13th Mar 2018, 4:26 PM
A Google User
A Google User - avatar