count days between two dates jquery code example

Example 1: javascript difference between two dates in days

const diffDays = (date, otherDate) => Math.ceil(Math.abs(date - otherDate) / (1000 * 60 * 60 * 24));

// Example
diffDays(new Date('2014-12-19'), new Date('2020-01-01'));   // 1839

Example 2: count days between two dates jquery

<!DOCTYPE html><html><head>    <title>Jquery get difference between two dates in days example - ItSolutionStuff.com</title></head><body>  <script type="text/javascript">   var days = daysdifference('10/11/2019', '10/20/2019');  console.log(days);  function daysdifference(firstDate, secondDate){    var startDay = new Date(firstDate);    var endDay = new Date(secondDate);       var millisBetween = startDay.getTime() - endDay.getTime();    var days = millisBetween / (1000 * 3600 * 24);       return Math.round(Math.abs(days));}</script>   </body></html>