在项目开发过程中,尝尝需要转换为年月日时分秒格式。
function processingTime() {
let d = new Date();
d =
d.getFullYear() +
"-" +
(d.getMonth() + 1 > 9 ? d.getMonth() + 1 : "0" + (d.getMonth() + 1)) +
"-" +
(d.getDate() > 9 ? d.getDate() : "0" + d.getDate()) +
" " +
(d.getHours() > 9 ? d.getHours() : "0" + d.getHours()) +
":" +
(d.getMinutes() > 9 ? d.getMinutes() : "0" + d.getMinutes()) +
":" +
(d.getSeconds() > 9 ? d.getSeconds() : "0" + d.getSeconds());
return d;
}
console.log(processingTime());