दो डेट्स के बीच दिनों की संख्या प्राप्त करने के लिए Math.floor() मेथड का उपयोग करें।
उदाहरण
दो डेट्स के बीच दिन प्राप्त करने के लिए निम्न कोड चलाएं:
<html>
<head>
<title>JavaScript Get Days</title>
</head>
<body>
<script>
var date1, date2;
date1 = new Date();
document.write("" + date1);
date2 = new Date("Dec 10, 2015 20:15:10");
document.write("<br>" + date2);
// दो डेट्स के बीच कुल सेकंड प्राप्त करें
var res = Math.abs(date1 - date2) / 1000;
var days = Math.floor(res / 86400);
document.write("<br>Difference: " + days);
</script>
</body>
</html>
आउटपुट
Mon May 28 2018 09:32:56 GMT+0530 (India Standard Time) Thu Dec 10 2015 20:15:10 GMT+0530 (India Standard Time) Difference: 899