在操作时间的时候,很多时候需要转化,年月日,时分秒等,每次封装js也是比较麻烦,推荐使用moment.js库。

网站链接:

http://momentjs.cn/docs/#/parsing/special-formats/

 

例如:

 formatGetTimes(val) {
      return moment(val).format("HH:mm:ss");
    },


// 把秒转化为多少小时多少分的形式
 filterFormatSeconds(val) {
      let times = moment(val).format("HH:mm");
      let arr = times.split(":");
      return arr[0] + "小时" + arr[1] + "分";
    }


// 这也是一种
moment(res.data.clockIn, "HH:mm:ss")

// 获得当前的时间  格式 年月
moment().format("YYYY-MM")

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-30
  • 2021-12-11
  • 2021-12-10
  • 2021-10-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案