You need to use currentDate with the help of new Date().getDate(). The syntax is as follows −
var anyVariableName= yourCurrentDate - yourSubstractDateOfCurrentMonth;
Example
var currentDate=new Date().getDate(); var substractDate=new Date("2020-07-01").getDate(); const numberOfDaysInCurrentMonthOnly = currentDate-substractDate; console.log(numberOfDaysInCurrentMonthOnly);
Note
Today’s date is - 28-07-2020
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo129.js
PS C:\Users\Amit\JavaScript-code> node demo129.js 27