const monthParsed = new Date(Date.parse(`${3} 1, ${1992}`)).

  • 本文关键字:Date 1992 monthParsed const new parse javascript
  • 更新时间 :
  • 英文 :

const monthParsed = new Date(Date.parse(`${3} 1, ${1992}`)).getMonth();  
const yearParsed = parseInt(1992, 0);   
console.log(new Date(yearParsed, monthParsed, 1, 0, 0, 0, 0).toISOString()); 

如果我运行上面的代码,month显示为->但是我想把输出显示为1992-03-29T18:30:00.000Z

getMonth返回以零为索引的月份-您需要添加一个以获得所需的值:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth

最新更新