Discuss / JavaScript / 请教下如何获得`1990-1-1 00:00:00`的日期

请教下如何获得`1990-1-1 00:00:00`的日期

Topic source

玩转ACE

#1 Created at ... [Delete] [Delete and Lock User]

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

请教下各位路过的大佬,老师有空的话也帮忙解答下,谢谢啦~~

🌙

#2 Created at ... [Delete] [Delete and Lock User]

区分一下date类型和字符串


  • 1

Reply