formatDate(value) { // 时间戳转换日期格式方法
const date = new Date(value)
const y = date.getFullYear()// 年
let MM = date.getMonth() + 1 // 月
MM = MM < 10 ? ('0' + MM) : MM
let d = date.getDate() // 日
d = d < 10 ? ('0' + d) : d
return y + '-' + MM + '-' + d
},
时间格式转化为yy-MM-dd
文章介绍了如何使用JavaScript中的`getFullYear`,`getMonth`,和`getDate`方法将时间戳转换为年-月-日格式的字符串,通过添加前导零处理月份和日期不足两位的情况。

2195

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



