zoukankan      html  css  js  c++  java
  • 获取当前季的js

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <script type="text/javascript">
    //获得本季度的开始月份 
    function getQuarterStartMonth() {
    var quarterStartMonth = "";
    var now = new Date();
    var nowMonth = now.getMonth();
    var nowYear = now.getFullYear(); //当前年
    
    if (nowMonth < 3) {
    quarterStartMonth = nowYear + '-' + '01-01';
    }
    if (2 < nowMonth && nowMonth < 6) {
    quarterStartMonth = nowYear + '-' + '04-01';
    }
    if (5 < nowMonth && nowMonth < 9) {
    quarterStartMonth = nowYear + '-' + '07-01';
    }
    if (nowMonth > 8) {
    quarterStartMonth = nowYear + '-' + '10-01';
    }
    // alert("这是季起始日期"+getQuarterEndMonth(quarterStartMonth));// 起始日期
    alert("这是季结束日期"+quarterStartMonth); //结束日期
    
    }
    
    
    // function getQuarterEndMonth(str_dt) {
    // //var str_dt = '2011-12-16';
    // var day = str_dt.substring(str_dt.lastIndexOf('-') + 1); //获取源数据的天数值,这里是31
    
    // var dt = new Date(str_dt);
    // var result = [];
    
    // dt.setMonth(dt.getMonth() - 15); //这边是减5季 ,因为每季3个月。所以是15个月
    
    // result.push(dt.getFullYear());
    
    // //计算结果日期值<源数据日期值时,说明日期值超过当月最大天数,日期值修改为当月最大天数值
    // if (dt.getDate() < day) {
    // result.push(dt.getMonth());
    // dt.setDate(0);
    // }
    // else result.push(dt.getMonth() + 1);
    // result.push(dt.getDate());
    // return result.join('-');
    // }
    </script>
    </head>
    <body>
    <div>
    <input type="button" onclick="getQuarterStartMonth()" />
    </div>
    </body>
    </html>
    

      

  • 相关阅读:
    RPA-UiPath视频教程2
    skywalking链路监控
    RPA-UiPath视频教程1
    Redis基础与性能调优
    tomcat调优
    DDos、CC攻击与防御
    UiPath官方视频Level2
    UiPath直播课程
    UiPath手把手教程
    【0】python核心编程,第二章
  • 原文地址:https://www.cnblogs.com/wdw31210/p/2557707.html
Copyright © 2011-2022 走看看