时间

  getTime(nowTime) {
      if (nowTime) {
        var date = new Date(nowTime);
      } else {
        var date = new Date();
      }
      let y = date.getFullYear();
      let m = (date.getMonth() + 1).toString().padStart(2, "0");
      let r = date.getDate().toString().padStart(2, "0");
      let hh = date.getHours().toString().padStart(2, "0");
      let mm = date.getMinutes().toString().padStart(2, "0");
      let ss = date.getSeconds().toString().padStart(2, "0");
      let week = date.getDay(); //星期
      let weeks = ["日", "一", "二", "三", "四", "五", "六"]; //判断星期几
      let getWeek = "星期" + weeks[week];
      return `${y} / ${m} / ${r} (${getWeek}) ${hh}:${mm}:${ss}`;
    },

 

上一篇:Ant Design of Vue月度选择框(MonthPicker)、前端获取到当前时间,把1-9月份拼“0”后赋值给月度选择框(扩展运算符、padStart)


下一篇:时间戳转化格式