elementUI moment 年月日转时间戳 时间限制

复制代码
      changeStartTime(val){
        debugger
        this.startT = val
        // this.startTime = parseInt(val.split('-').join(''))
        this.startTime = moment(val).unix() * 1000 //开始时间毫秒
        if(this.endTime){
          this.endTime = moment(this.endT).unix() * 1000 //结束时间毫秒
          if(this.startTime - this.endTime >= 0){
            this.$message.warning('培训开始时间不能大于培训结束时间!')
            this.form.trainTime = ''
            this.form.trainDuration = ''
          }else{
            const sc = (this.endTime - this.startTime) /1000 / 60 / 60 + 'h'
            this.form.trainDuration = sc
          }
        }
      },
      changeEndTime(val){
        this.endT = val
        // this.endTime = parseInt(val.split('-').join(''))
        this.endTime = moment(val).unix() * 1000 //开始时间毫秒
        if(this.startTime){
          this.startTime = moment(this.startT).unix() * 1000 //结束时间毫秒
          if(this.endTime - this.startTime <=0 ){
            this.$message.warning('培训结束时间不能小于培训开始时间!')
            this.form.completeTime = ''
            this.form.trainDuration = ''
          }else{
            const sc = (this.endTime - this.startTime) /1000 / 60 / 60 + 'h'
            this.form.trainDuration = sc
          }
        }
      },
相关推荐
Jonathan Star1 天前
沉浸式雨天海岸:用A-Frame打造WebXR互动场景
前端·javascript
工业甲酰苯胺1 天前
实现 json path 来评估函数式解析器的损耗
java·前端·json
老前端的功夫1 天前
Web应用的永生之术:PWA落地与实践深度指南
java·开发语言·前端·javascript·css·node.js
LilySesy1 天前
ABAP+WHERE字段长度不一致报错解决
java·前端·javascript·bug·sap·abap·alv
Wang's Blog1 天前
前端FAQ: Vue 3 与 Vue 2 相⽐有哪些重要的改进?
前端·javascript·vue.js
再希1 天前
React+Tailwind CSS+Shadcn UI
前端·react.js·ui
用户47949283569151 天前
JavaScript 的 NaN !== NaN 之谜:从 CPU 指令到 IEEE 754 标准的完整解密
前端·javascript
群联云防护小杜1 天前
国产化环境下 Web 应用如何满足等保 2.0?从 Nginx 配置到 AI 防护实战
运维·前端·nginx
醉方休1 天前
Web3.js 全面解析
前端·javascript·electron
前端开发爱好者1 天前
前端新玩具:Vike 发布!
前端·javascript