Thu Nov 14 2019 16:10:11 GMT+080

2019-11-15  本文已影响0人  李寻欢_

直接将Thu Nov 14 2019 16:10:11 GMT+0800全部传入即可,无需做其他截取字符串处理的操作.

handleTime(time) {
      let d = new Date(time);
      let year = d.getFullYear();
      let month = d.getMonth() + 1;
      let day = d.getDate();
      let hour = d.getHours();
      let minute = d.getMinutes();
      let second = d.getSeconds();
      month = month < 10 ? "0" + month : month;
      day = day < 10 ? "0" + day : day;
      hour = hour < 10 ? "0" + hour : hour;
      minute = minute < 10 ? "0" + minute : minute;
      second = second < 10 ? "0" + second : second;

      let result =
        year +
        "-" +
        month +
        "-" +
        day +
        " " +
        hour +
        ":" +
        minute +
        ":" +
        second;
      return result;
    },

处理结果:


处理结果.png
上一篇下一篇

猜你喜欢

热点阅读