function buildDate({year, month, day, hour=0, minute=0, second=0}) {
return new Date(year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second);
}
console.log(buildDate({year: 2021,month:1,day:1})); // 2020-12-31T16:00:00.000Z
请教下各位路过的大佬,老师有空的话也帮忙解答下,谢谢啦~~
区分一下date类型和字符串
Sign in to make a reply
玩转ACE
function buildDate({year, month, day, hour=0, minute=0, second=0}) {
return new Date(year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second);
}
console.log(buildDate({year: 2021,month:1,day:1})); // 2020-12-31T16:00:00.000Z
请教下各位路过的大佬,老师有空的话也帮忙解答下,谢谢啦~~