console
var date = new Date();
var day;
function getNowMonth() {
var dat = [];
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth() + 1;
day = date.getDate();
var lastDay = getLastDay(year, month);
dat.push(year, month, day, lastDay);
console.log(dat)
}
function getPreMonth() {
var dat = [];
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth();
day = date.getDate();
if (month == 0) {
year = year - 1;
month = 12;
}
var lastDay = getLastDay(year, month);
dat.push(year, month, day, lastDay);
console.log(dat)
}
function getLastDay(year, month) {
var new_year = year;
var new_month = month++;
if (month > 12) {
new_month -= 12;
new_year++;
}
var new_date = new Date(new_year, new_month, 1);
return (new Date(new_date.getTime() - 1000 * 60 * 60 * 24)).getDate();
}
function PregeMonth(date) {
if (!date) {
console.log(111111)
} else {
console.log(date)
}
}
PregeMonth();
var itm=new Date('2019-03-30');
console.log(itm.getDate())