ES6,时间格式yyyy-MM-dd HH:MM:SS

    setNowFormatDate() {
      let date = new Date();
      let month = (date.getMonth() + 1).toString().padStart(2,'0');
      let strDate = date.getDate().toString().padStart(2,'0');
      //时间格式yyyy-MM-dd HH:MM:SS
      return `${date.getFullYear()}-${month}-${strDate} ${this.getCurrentTime()}`;
    },
    getCurrentTime() {
      let date = new Date();
      //时间格式HH:MM:SS
      return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
    },

  

猜你喜欢

转载自www.cnblogs.com/tabCtrlShift/p/9178970.html