js获取上个月份的季度

function getJiDu(month) {
                if(month  <= 3) {
                    return '1';
                }else if(month <= 6) {
                    return '2';
                }else if(month <=9) {
                    return '3';
                }else if(month <=12) {
                    return '4';
                }
            }
           var z=new Date().getMonth();
           var z=((z==0)?(12):(z));
           alert(getJiDu(z));

获取上个月月份
dt.setMonth(dt.getMonth() - 1);
即使月份不够减的,也能正确返回结果

猜你喜欢

转载自blog.csdn.net/qq_32711309/article/details/86220441