12-26-2022, 04:47 AM
We will get date in yyyy-mm-dd format
var date = new Date();
var curr_month = date.getMonth();
var currentYear = date.getFullYear();
function padTo2Digits(num) {return num.toString().padStart(2, '0');}
function cur_month(date) {
return [
date.getFullYear(),
padTo2Digits(date.getMonth() + 1),
padTo2Digits(date.getDate()),
].join('-');
}
var curmonth_start = cur_month(new Date(currentYear, curr_month, 1)) );
var curmonth_end = cur_month(new Date(currentYear, curr_month + 1, 0)) );
var date = new Date();
var curr_month = date.getMonth();
var currentYear = date.getFullYear();
function padTo2Digits(num) {return num.toString().padStart(2, '0');}
function cur_month(date) {
return [
date.getFullYear(),
padTo2Digits(date.getMonth() + 1),
padTo2Digits(date.getDate()),
].join('-');
}
var curmonth_start = cur_month(new Date(currentYear, curr_month, 1)) );
var curmonth_end = cur_month(new Date(currentYear, curr_month + 1, 0)) );