aspose file tools*
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 Spring in Action this week in the Spring 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