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>
    

      

  • 相关阅读:
    HarmonyOS 对象数据库
    springboot 整合/集成 jpa
    linux 安装docker和mysql
    HarmonyOS 多线程
    ElasticSearch 安装及配置 搭建集群
    java 集合
    HarmonyOS 基础数据库
    ElasticSearch 基本操作
    Windows驱动wdf驱动开发系列(一)
    32进程调用64dll的解决方法
  • 原文地址:https://www.cnblogs.com/wdw31210/p/2557707.html
Copyright © 2011-2022 走看看