美文网首页
Thu Nov 14 2019 16:10:11 GMT+080

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

作者: 李寻欢_ | 来源:发表于2019-11-15 16:59 被阅读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

    相关文章

      网友评论

          本文标题:Thu Nov 14 2019 16:10:11 GMT+080

          本文链接:https://www.haomeiwen.com/subject/jousictx.html