Bạn cần sử dụng currentDate với sự giúp đỡ của new Date().getDate(). Cú pháp như sau:
var anyVariableName = yourCurrentDate - yourSubstractDateOfCurrentMonth;
Ví dụ
var currentDate = new Date().getDate();
var substractDate = new Date("2020-07-01").getDate();
const numberOfDaysInCurrentMonthOnly = currentDate - substractDate;
console.log(numberOfDaysInCurrentMonthOnly);
Lưu ý
Ngày hôm nay là - 28-07-2020
Để chạy chương trình trên, bạn cần sử dụng lệnh sau:
node fileName.js
Tên tệp của tôi là demo129.js
PS C:\Users\Amit\JavaScript-code> node demo129.js 27