let t = new Date();
const doDate = {
gY: t => {
return t.getFullYear();
},
gMo: t => {
return t.getMonth() + 1 >= 10 ? t.getMonth() + 1 : `0${t.getMonth() + 1}`;
},
gD: t => {
return t.getDate() >= 10 ? t.getDate() : `0${t.getDate()}`;
},
gH: t => {
return t.getHours() >= 10 ? t.getHours() : `0${t.getHours()}`;
},
gM: t => {
return t.getMinutes() >= 10 ? t.getMinutes() : `0${t.getMinutes()}`;
},
gS: t => {
return t.getSeconds() >= 10 ? t.getSeconds() : `0${t.getSeconds()}`;
}
};
this.sendToTime = doDate.gY(t)+'-'+doDate.gMo(t)+'-'+doDate.gD(t)+' '+doDate.gH(t)+':'+doDate.gM(t)+':'+doDate.gS(t);
js获取年月
于 2023-05-15 15:43:26 首次发布