Get Date Difference between two Dates in JavaScript using Moment

Share:
Best way to get the difference between two dates in days.

Suppose from Date is "27-04-2018" and To Date is "29-04-2018"
The Date format will be "DD-MM-YYYY"
var  dateDiff = getDateDifference("27-04-2018", "29-04-2018", "DD-MM-YYYY");
Output: 2

Common Function:
Using Moment.js you can Parse, validate, manipulate, and display dates and times in JavaScript. Moment.js is freely distributable under the terms of the MIT license.
Moment is available in more than 123 Languages.

You can download Moment.js from Moment's official website https://momentjs.com/

OR

Visit below URL to get CDN for Moment.js
https://www.codebrary.com/2018/03/moment-library-cdn.html


Hi! I am Sartaj Husain. I am a Professional Software Developer, live in Delhi. I write blogs in my free time. I love to learn and share the knowledge with others because it is no good to try to stop knowledge from going forward. So free posts and tutorials. more..

No comments