流浪のwolf

卷帝

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

element输入天数,获取当前时间加上天数 【时间获取】

复制代码
    handleInput (val) {
      // console.log(this.formModel.ITEM_PM)
      if (!(/[^\d]/g).test(val)) {
        // console.log('非数字')
        // 当前时间加上PM天数
        console.log(val)
        let now = new Date()
        let result = this.defaulTime2(now, Number(val))
        this.formModel.ITEM_PMTIME = result
      }
    },
    defaulTime2 (now, d) {
      //把时分秒设置为0,不需要就直接注释掉就好了
      // now.setHours(0)
      // now.setMinutes(0)
      // now.setSeconds(0)
      now.setDate(now.getDate() + d)
      now = this.formatDate(now)  //用了上面转年月日的方法
      // now = now.toLocaleDateString(); //自带的年月小于10时,没有自动补0,所以用了自己的方法,看自己需要
      return now
    },
    formatDate (date) {
      const year = date.getFullYear()
      const month = date.getMonth() + 1
      const day = date.getDate()
      const hour = date.getHours()
      const mintu = date.getMinutes()
      const second = date.getSeconds()
      return [year, month, day].map(val => {
        // console.log(val)
        return val
      }).join('-') + " " + `${hour}:${mintu}:${second}`
    },
复制代码

 

posted on   朱龙旭的网络  阅读(24)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· Blazor Hybrid适配到HarmonyOS系统
· 支付宝 IoT 设备入门宝典(下)设备经营篇
· 万字调研——AI生成内容检测
· 解决跨域问题的这6种方案,真香!
· 一套基于 Material Design 规范实现的 Blazor 和 Razor 通用组件库
点击右上角即可分享
微信分享提示