重新编写日期格式 YYYY-MM_DD


//重新编写时间格式YYYY-MM_DD
function getDateStr3(date) {
console.log('date',date);
var year = "";
var month = "";
var day = "";
var now = date;
year = "" + now.getFullYear();
if ((now.getMonth() + 1) < 10) {
month = "0" + (now.getMonth() + 1);
} else {
month = "" + (now.getMonth() + 1);
}
if ((now.getDate()) < 10) {
day = "0" + (now.getDate());
} else {
day = "" + (now.getDate());
}
return year + "-" + month + "-" + day;
}
原文地址:https://www.cnblogs.com/whdaichengxu/p/12711942.html