js根据当前季度获取季度时间范围

格式化时间(yy--mm--dd)

Listfu(date) {     

var myyear = date.getFullYear();

var mymonth = date.getMonth() + 1;   

var myweekday = date.getDate();     

if (mymonth < 10) {        mymonth = "0" + mymonth;      }     

if (myweekday < 10) {        myweekday = "0" + myweekday;      }     

return myyear + "-" + mymonth + "-" + myweekday;   

},

根据季度获取

month:第几季度

formatOp(month) {

      var newmonth;

      var newmonth1;

      if (month < 3) {

        newmonth = new Date(new Date().setMonth(0));

        newmonth1 = new Date(new Date().setMonth(3));

      } else if (2 < month && month < 6) {

        newmonth = new Date(new Date().setMonth(3));

        newmonth1 = new Date(new Date().setMonth(6));

      } else if (5 < month && month < 9) {

        newmonth = new Date(new Date().setMonth(6));

        newmonth1 = new Date(new Date().setMonth(9));

      } else if (8 < month && month < 11) {

        newmonth = new Date(new Date().setMonth(9));

        newmonth1 = new Date(new Date().setMonth(12));

      }

      var thisseason1 = new Date(newmonth.setDate(1));

      var thisseason2 = new Date(newmonth1.setDate(0));

      return [this.Listfu(thisseason1), this.Listfu(thisseason2)];

    },

你可能感兴趣的:(js根据当前季度获取季度时间范围)