1. //获取系统当前时间
    2.  
      var nowdate = new Date();
    3.  
      var y = nowdate.getFullYear();
    4.  
      var m = nowdate.getMonth()+1;
    5.  
      var d = nowdate.getDate();
    6.  
      var formatnowdate = y+'-'+m+'-'+d;
    7.  
      $("#enddate").datebox("setValue",formatnowdate);
    8.  
      //获取系统前一周的时间
    9.  
      var oneweekdate = new Date(nowdate-7*24*3600*1000);
    10.  
      var y = oneweekdate.getFullYear();
    11.  
      var m = oneweekdate.getMonth()+1;
    12.  
      var d = oneweekdate.getDate();
    13.  
      var formatwdate = y+'-'+m+'-'+d;
    14.  
      $("#fdate").datebox("setValue",formatwdate);
    15.  
      //获取系统前一个月的时间
    16.  
      nowdate.setMonth(nowdate.getMonth()-1);
    17.  
      var y = nowdate.getFullYear();
    18.  
      var m = nowdate.getMonth()+1;
    19.  
      var d = nowdate.getDate();
    20.  
      var formatwdate = y+'-'+m+'-'+d;
    21.  
      $("#fdate").datebox("setValue",formatwdate);
    22.  

posted on 2018-10-25 14:44  假装新手  阅读(139)  评论(0编辑  收藏  举报