获取当月的某天

Tools.getMonthDate = function(type) {
    var res = false,
        today = new Date(),
        year = today.getFullYear(),
        month = today.getMonth() + 1,
        splitor = '-'

    month = Tools.DateUtil._fillUpData(month)

    switch(type) {
        case 'today': 
            res = year + splitor + month + splitor + Tools.DateUtil._fillUpData(today.getDate())
            break;
        case 'first': 
            res = year + splitor + month + splitor + '01'
            break;
        case 'last': 
            var date = new Date(year, month, 0)
            res = year + splitor + month + splitor + date.getDate()
            break;
        default:break;   
    }

    return res
}
原文地址:https://www.cnblogs.com/javawer/p/4171363.html