格式化时间的js库moment.js
在操作时间的时候,很多时候需要转化,年月日,时分秒等,每次封装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")

浙公网安备 33010602011771号