zoukankan      html  css  js  c++  java
  • new Data()获取到的值改为2019-11-16 12:35:00的格式

    写的是移动端,用的vant中的时间组件。但是这个时间便利方法是公用的。能够将new Data()的值变为2019-11-16 12:35:00的格式

     /**
         * 选择时间确认事件
         * @author ex_maruihua
         * @updata ex_maruihua(2019/11/26--09点44分)
         * @param {Date} val 用户选择的时间结果
         */
        okdatetime(val) {
          const d = new Date(val);
          const resDate =
            d.getFullYear() +
            '-' +
            this.p(d.getMonth() + 1) +
            '-' +
            this.p(d.getDate());
          const resTime =
            this.p(d.getHours()) +
            ':' +
            this.p(d.getMinutes()) +
            ':' +
            this.p(d.getSeconds());
          this.isdatatime = false;
          this.lossDate = resDate + ' ' + resTime;
          return resDate + ' ' + resTime;
        },
        /**
         * 时间遍历方法
         * @author ex_maruihua
         * @updata ex_maruihua(2019/12/26--09点44分)
         * @param {Date} s 得到的时间结果
         */
        p(s) {
          return s < 10 ? '0' + s : s;
        },
  • 相关阅读:
    DHCP
    NFS
    GlusterFS
    作文学习笔记[1]
    围绕中心进行写作
    阅读学习笔记[1]
    作文学习笔记[2]
    心理描写的方法
    多彩的活动
    阅读理解答题步骤
  • 原文地址:https://www.cnblogs.com/maruihua/p/12018052.html
Copyright © 2011-2022 走看看