Hello to all, welcome to therichpost.com. In this post, I will tell you, How to get month difference between two dates?
I like jQuery the most and in my all the project, I do my all the things done with jquery.
In this post, I will tell and How to get month difference between two dates? with help of jquery.
Here is the working code snippet and you can add this code into your HTML file easily:
Old Date(2019 january): <span class="OldDate">2/10/2019</span> Today(september month 2019): <span class="Todaydate">9/10/2019</span> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> jQuery(document).ready(function($) { var OldDate = $(".OldDate").text(); var Newdate = $(".Todaydate").text(); var oldD = new Date(OldDate); var newD = new Date(Newdate); //This alert will show you months diffrence alert((newD.getMonth()+1)-(oldD.getMonth()+1)); }) </script>
This is just demo working code and you can modify it with your own requirement.
Jassa Jatt.
Thank you
Recent Comments