This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes HTML, CSS and JavaScript and the fly likes Get Number of Months From two Dates using Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Get Number of Months From two Dates using Javascript" Watch "Get Number of Months From two Dates using Javascript" New topic
Author

Get Number of Months From two Dates using Javascript

Sreenivas Reddy Tatikunta
Greenhorn

Joined: Aug 23, 2011
Posts: 24

Hi All,


I have following dates in javascript,

var date1 = 05-30-2011
var date2= 08-23-2011(Current Date)

It should compare both dates and return number months. This example result is 2 months 23 days (Here days not required only should return exact months). Using javascript.

If anyone have idea could you please help me...


Thanks & Regards
Sreenivas Reddy.T
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Looks like you need:

  • new Date()
  • getFullYear()
  • getMonth()


  • Eric
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Get Number of Months From two Dates using Javascript