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
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply 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: 15357
    
    6
Looks like you need:

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


  • Eric
     
    I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
     
    subject: Get Number of Months From two Dates using Javascript
     
    Similar Threads
    Date
    Problem with javascript dates
    How to convert Number of Days to MM and DD
    Can anyone send me the code to calculate the years/months/days between the tow dates.
    resultset is not working properly