function other(m){return m<10?'0'+m:m },
// 时间蹉转换成日期
function time(time){
//接收一个时间戳, time是整数,否则要parseInt转换
let timer = new Date(time);
let y = timer.getFullYear();
let m = timer.getMonth()+1;
let d = timer.getDate();
let h = timer.getHours();
let mm = timer.getMinutes();
let s = timer.getSeconds();
// return y+'-'+m+'-'+d+' '+h+':'+mm+':'+s;
// 我这里只获取年月日
return y + '-' + this.other(m) + '-' + this.other(d)
},
JavaScript将时间戳转为日期
最新推荐文章于 2024-07-02 00:30:00 发布