Click here to Skip to main content
12,820,108 members (23,279 online)
Rate this:
Please Sign up or sign in to vote.
See more: Javascript
Hi friends...

i am using jquery plugin for datepicker.

in this i get month/day/year format

so i have 2 text feild for dates


textfeild1: 09/24/2012

textfeild1: 12/25/2012

then i want to find out no of months between these 2 dates

plz help me... for this i am frustating from more days

Thanks & Regards

Mallesh(emailid deleted)
Posted 15-Jan-13 2:15am
Updated 15-Jan-13 2:34am
AshishChaudha 15-Jan-13 7:29am
Don't repeat the question please.
Sandeep Mewara 15-Jan-13 13:49pm
Why, where are you stuck?
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Compliments of This answer
//Set the two dates
var currentTime   = new Date()
var currDate      = currentTime.getMonth() + 1 + "/" + currentTime.getDate() + "/" + currentTime.getFullYear() //Todays Date - implement your own date here.
var iniPastedDate = "8/7/2012" //Pasted Date - Implement your own date here.

//currDate = 8/17/12 and iniPastedDate = 8/7/12

function DateDiff(date1, date2) {
    var datediff = date1.getTime() - date2.getTime(); //store the getTime diff - or +
    return (datediff / (24*60*60*1000)); //Convert values to -/+ days and return value      

//Write out the returning value should be using this example equal -10 which means 
//it has pasted by ten days. If its positive the date is coming +10.    
document.write (DateDiff(new Date(iniPastedDate),new Date(currDate))); //Print the results...

The only thing you have to do from this answer is to get the month diff value.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Marcus Kramer 15-Jan-13 11:48am
The OP is asking for a javascript solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170308.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100