快速获取当前年月日,随笔

getCurrentDate() {
  let date = new Date()
  let year = date.getFullYear()
  let month = String(date.getMonth() + 1).padStart(2, '0') // 月份从0开始,需要加1,并补零
  let day = String(date.getDate()).padStart(2, '0') // 补零
  return `${year}-${month}-${day}`
},

posted @ 2025-03-04 08:44  dmyling  阅读(12)  评论(0)    收藏  举报