new Date().getDate() দিয়ে বর্তমান তারিখ পাওয়া যায়। তারপর বিয়োগ করলে দিনের পার্থক্য পাওয়া যায়। নোট: এটি শুধু একই মাসের তারিখের জন্য কাজ করে।
উদাহরণ
var currentDate = new Date().getDate();
var substractDate = new Date("2020-07-01").getDate();
const numberOfDaysInCurrentMonthOnly = currentDate - substractDate;
console.log(numberOfDaysInCurrentMonthOnly);
কমান্ড: node fileName.js
আউটপুট
PS C:\Users\Amit\JavaScript-code> node demo129.js 27