搬砖 - js获取某月最后一天

function setDefaultReviewPeriodDate(){
    var year = new Date().getFullYear();
    var month = new Date().getMonth();
    month = month - month % 3 + 3;
    console.info(year);

    // Get Last Day Of Month
    var date = new Date(year, month - 1, '01');
    date.setDate(1);
    date.setMonth(date.getMonth() + 1);
    var cdate = new Date(date.getTime() - 1000 * 60 * 60 * 24);
    var day = cdate.getDate();
    $("#inpReviewPeriodDate").val(year + "-" + month + "-" + day);
}
function getLastDayOfMonth(year, month) {
    var date = new Date(year, month - 1, '01');
    date.setDate(1);
    date.setMonth(date.getMonth() + 1);
    var cdate = new Date(date.getTime() - 1000 * 60 * 60 * 24);
    return cdate.getDate();
}

 

posted @ 2020-11-30 00:59  雾中的-松  阅读(179)  评论(0编辑  收藏  举报