1.获取自定义时间格式(携补0操作)
let year = new Date().getFullYear();let month = new Date().getMonth() + 1 < 10 ? "0" + (new Date().getMonth() + 1) : new Date().getMonth() + 1;let date = new Date().getDate() < 10 ? "0" + new Date().getDate() : new Date().getDate();let hh = new Date().getHours() < 10 ? "0" + new Date().getHours() : new Date().getHours();let mm = new Date().getMinutes() < 10 ? "0" + new Date().getMinutes() : new Date().getMinutes() + 1;let ss = new Date().getSeconds() < 10 ? "0" + new Date().getSeconds() : new Date().getSeconds();// this.nowDate = year + ":" + month + ":" + date + ""; // 年月日// this.nowTime = hh + ":" + mm ; // 时分let_time = year + "-" + month + "-" + date + " " + hh + ":" + mm;let newTime=year + ":" + month + ":" + date + ""+hh + ":" + mm;
