Difference in Months between two dates in JavaScript

后端 未结 26 2911
南方客
南方客 2020-11-22 17:06

How would I work out the difference for two Date() objects in JavaScript, while only return the number of months in the difference?

Any help would be great :)

26条回答
  •  再見小時候
    2020-11-22 18:02

    One approach would be to write a simple Java Web Service (REST/JSON) that uses JODA library

    http://joda-time.sourceforge.net/faq.html#datediff

    to calculate difference between two dates and call that service from javascript.

    This assumes your back end is in Java.

提交回复
热议问题