对于标准时间转换为日常年月日时分秒标准格式补零的
作者:互联网
对于标准时间转换为日常年月日时分秒标准格式补零的
function getDateString(date) {
var year = date.getFullYear().toString().padStart(4, "0");
var month = (date.getMonth() + 1).toString().padStart(2, "0");
var day = date.getDate().toString().padStart(2, "0");
var hour = date.getHours().toString().padStart(2, "0");
var minute = date.getMinutes().toString().padStart(2, "0");
var second = date.getSeconds().toString().padStart(2, "0");
return `${year}- ${month}-${day} ${hour}:${minute}:${second}`;
}
标签:month,padStart,var,标准,second,toString,date,补零,时分秒 来源: https://blog.csdn.net/Fairyasd/article/details/114142416