export function getFormatDate(time) {
let date = new Date(time);
let Str=date.getFullYear() + ‘-’ +
((date.getMonth() + 1).toString().length==1?’0’+(date.getMonth()+1):date.getMonth()+1) + ‘-’ +
(date.getDate().toString().length==1?’0’+date.getDate():date.getDate() ) + ’ ’ +
(date.getHours().toString().length==1?’0’+date.getHours():date.getHours() )+ ‘:’ +
(date.getMinutes().toString().length==1?’0’+date.getMinutes():date.getMinutes())+ ‘:’ +
(date.getSeconds().toString().length==1?’0’+date.getSeconds():date.getSeconds());
return Str;
}
原生jsDate()时间转换为yyyy-MM-dd 时:分:秒的格式
最新推荐文章于 2024-11-20 20:21:54 发布