zoukankan      html  css  js  c++  java
  • 获取日期操作

    (1)

    value(3):月  startdate:上个月的第一天 enddate:上个月的最后一天

    value(5):年  startdate:去年当前月的第一天 enddate:上个月的最后一天

    function changestartorendtime(value){
    	 computecycle = value;
    	 var myDate = new Date();
    	 var new_year = myDate.getFullYear();    //取当前的年份        
    	 var new_month = myDate.getMonth();        
    	 var new_enddate = new Date(new_year,new_month,1);
    	 enddate = new Date(new_enddate.getTime()-1000*60*60*24).toLocaleDateString().replace(/[/]/g,"-");
    	 var new_yearstartdate = new Date(new_year-1,new_month,1).toLocaleDateString().replace(/[/]/g,"-");
    	 var new_monthstartdate = new Date(new_year,new_month-1,1).toLocaleDateString().replace(/[/]/g,"-");
    	 startdate=(value==5)?new_yearstartdate:new_monthstartdate;
    }
    

     (2)

    生成之前12个月的月份(YYYY-MM)

    function gethistorymonth(){
        var myDate = new Date();
         var new_year = myDate.getFullYear()-1;    
         var new_month = myDate.getMonth()+1; 
         $("div[name=month]").empty();
         for(i = 0;i < 12;i++){
             if(new_month>12){
                 new_year++;
                 new_month=1;
             }
             var datestr = (new_month<10)?new_year+"-0"+new_month:new_year+"-"+new_month;
             new_month++;
             $("div[name=month]").append(datestr+"###");
         }
    }
  • 相关阅读:
    CDH执行spark任务
    CDH日志目录
    CDH5.12安装遇到的坑
    Scala 运行jar命令
    二进制
    build 文件夹中的 webpack.prod.conf.js
    build 文件夹中的 check-versions.js
    build 文件夹中的 webpack.prod.conf.js
    build 文件夹中的 webpack.dll.config.js
    build 文件夹中的 webpack.dev.conf.js
  • 原文地址:https://www.cnblogs.com/soup227/p/5941025.html
Copyright © 2011-2022 走看看