欢迎光临
我们一直在努力

VUE3将时间戳转换为时间格式

 

formatDate(time) {
const date = new Date(time*1000);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, ‘0’); // 月份从0开始,所以加1,并用0填充
const day = String(date.getDate()).padStart(2, ‘0’); // 用0填充
const hours = String(date.getHours()).padStart(2, ‘0’); // 用0填充
const minutes = String(date.getMinutes()).padStart(2, ‘0’); // 用0填充
return `${year}-${month}-${day} ${hours}:${minutes}`;
}

未经允许不得转载:大有博文 » VUE3将时间戳转换为时间格式
分享到: 更多 (0)

大前端WP主题 更专业 更方便

联系我们联系我们