उदाहरण
new Date().getDate() से वर्तमान तारीख प्राप्त करें और घटाएं।
var currentDate = new Date().getDate();
var substractDate = new Date("2020-07-01").getDate();
const numberOfDaysInCurrentMonthOnly = currentDate - substractDate;
console.log(numberOfDaysInCurrentMonthOnly);
नोट: आज की तारीख 28-07-2020 है।
प्रोग्राम चलाने के लिए:
node fileName.js
आउटपुट
PS C:\Users\Amit\JavaScript-code> node demo129.js 27