let timeFormatSeconds = function(time) {
let d = time ? new Date(time) : new Date();
let year = d.getFullYear();
let month = d.getMonth() + 1;
let day = d.getDate();
let hours = d.getHours();
let min = d.getMinutes();
let seconds = d.getSeconds();
if (month < 10) month = '0' + month;
if (day < 10) day = '0' + day;
if (hours < 0) hours = '0' + hours;
if (min < 10) min = '0' + min;
if (seconds < 10) seconds = '0' + seconds;
return (year + '-' + month + '-' + day + ' ' + hours + ':' + min + ':' + seconds);
}
标签:格式化,min,seconds,month,hours,时间,let,js,day
From: https://www.cnblogs.com/orangeczs/p/17514968.html