📜  获取日期格式 javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:20.736000             🧑  作者: Mango

代码示例1
//Date format
  const handleDate = (dataD) => {
    let data= new Date(dataD)
    let month = data.getMonth() + 1
    let day = data.getDate()
    let year = data.getFullYear()
    if(day<=9)
      day = '0' + day
    if(month<10)
      month = '0' + month
    const postDate = year + '-' + month + '-' + day
    return postDate
  }