• element ui datepicker 计算开始时间和结束时间的时间差


    getTime(beginTime, endTime) {
          var dateDiff = endTime.getTime() - beginTime.getTime(); //时间差的毫秒数
          var dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000)); //计算出相差天数
          var leave1 = dateDiff % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
          var hours = Math.floor(leave1 / (3600 * 1000)); //计算出小时数
          //计算相差分钟数
          var leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
          var minutes = Math.floor(leave2 / (60 * 1000)); //计算相差分钟数
          //计算相差秒数
          var leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
          var seconds = Math.round(leave3 / 1000);
          console.log(
            " 相差 " +
              dayDiff +
              "" +
              hours +
              "小时 " +
              minutes +
              " 分钟" +
              seconds +
              ""
          );
          return "相差 " + dayDiff + "" + hours + "小时 " + minutes + " 分钟";
        },
    开始时间和结束时间时间差
    <div class="des-status-df">开始</div>
                  <div class="block">
                    <el-date-picker
                     
                      v-model="startTime"
                      type="datetime"
                      placeholder="选择日期时间"
                      @change="jsTime"
                    >
                    </el-date-picker>
                  </div>
                  <div class="des-status-df">结束</div>
                  <div class="block">
                    <el-date-picker
                     
                      v-model="endTime"
                      type="datetime"
                      placeholder="选择日期时间"
                      @change="jsTime"
                    >
                    </el-date-picker>
                  </div>
                  <div class="des-time-box">
                    <span class="des-time">共计</span>
                    <span class="des-time-red">{{duration}}</span>
                    <span class="des-time">小时</span>
                  </div>
    data
    duration: "",
    startTime: "",
    endTime: "",
  • 相关阅读:
    Linux安装telnet
    linux 打压缩包
    JAVA读写文件
    LINUX安装NGINX
    Linux安装JDK
    java判断字符串中是否包含中文 过滤中文
    操作MySQL
    Java序列化对象-字符串转换
    nginx
    linux操作命令
  • 原文地址:https://www.cnblogs.com/shuihanxiao/p/15386444.html
Copyright © 2020-2023  润新知