timeFormat(originVal) {
// 将毫秒数转换为yyyy-m-d hh:mm:ss格式
const dt = new Date(originVal)
const y = dt.getFullYear();
const m = (dt.getMonth() + 1 + '').padStart(2, '0');
const d = (dt.getDate() + '').padStart(2, '0');
const hh = (dt.getMonth() + '').padStart(2, '0');
const mm = (dt.getMinutes() + '').padStart(2, '0');
const ss = (dt.getSeconds() + '').padStart(2, '0');
let tiem = y + "-" + m + "-" + d + " " + hh + ":" + mm + ":" + ss
return tiem;
},
VUE 前端将毫秒数转换成日期
最新推荐文章于 2025-03-11 17:25:35 发布
博客展示了一段JavaScript代码,定义了一个名为timeFormat的函数,用于将毫秒数转换为yyyy-m-d hh:mm:ss格式的日期时间。函数通过Date对象获取年、月、日、时、分、秒,并进行格式化处理后返回结果。
614

被折叠的 条评论
为什么被折叠?



