Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Months between two dates using Java Script

Status
Not open for further replies.

Techieto

Programmer
Jul 19, 2002
3
0
0
US
Is there a date function in Java Script to find months between two dates?

Or some user defined funtion to do the same.

Thanks.
 
If you've already created the Date() objects:

function datedifferencemonths(date1, date2)
{
var months1=date1.getMonth() + (date1.getFullYear() * 12);
var months2=date2.getMonth() + (date2.getFullYear() * 12);

return Math.abs(months1 - months2);
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top