zoukankan      html  css  js  c++  java
  • 关于日期

    // 2019年10月的格式转为201910
          const year = this.data.seleteTime.split("年")[0]
          let month = this.data.seleteTime.split("年")[1].split("月")[0]
    
    
     // 计算每个月的天数
          const thisDate = new Date(year, month, 0);
          // console.log(thisDate.getDate());
          const day = thisDate.getDate();
    
    // 如果月份小于10  改为 01 格式
          if (month < 10) {
            month = "0" + month
            // console.log(month)
          }
    
    //拼接每月第一天的时间为"20191001 00:00:00"
          beginDate: year + month + '01' + ' ' + '00:00:00', 
    
    //拼接每月最后一天时间为"20191031 23:59:59"
            endDate: year + month + day + ' ' + '23:59:59' 
    
    //截取日期 20191001
          const theDate = reqData.beginDate.split(' ')[0]
    
    //截取时间  00:00:00
          const theEnd = reqData.endDate.split(' ')[0]
    
    //将时间转为 2019-10-01
          var r = theDate.replace(/^(d{4})(d{2})(d{2})$/, "$1-$2-$3")
    
    //判断指定日期为星期几
              var arys1 = new Array();
              arys1 = '2019-10-01'.signDate.split('T')[0].split('-'); //日期为输入日期,格式为 2013-3-10
              const ssdate = new Date(arys1[0], parseInt(arys1[1] - 1), arys1[2]);
              const week1 = String(ssdate.getDay()).replace("0", "日").replace("1", "一").replace("2", "二").replace("3", "三").replace("4", "四").replace("5", "五").replace("6", "六"); //就是你要的星期几
              const week = "星期" + week1; //就是你要的星期几
  • 相关阅读:
    JQuery性能优化
    分页控件X.PagedList.Mvc
    《转》sql 、linq、lambda 查询语句的区别
    Linq的连表查询
    MVC页面直接F5出错
    详解集合
    Json的序列化与反序列化
    《转》dbcontext函数
    《转》jquery中的$.ajax的success与error
    cocos creator基础-(二十七)httpclient Get POST
  • 原文地址:https://www.cnblogs.com/tt-ff/p/11780062.html
Copyright © 2011-2022 走看看