一、获取上一月的“年月”

// 获取上一个月的年月
export const GetPreMonthYM = (cb) => {
  const getDate = new Date()
  // 获得当前年
  const getCurY = getDate.getFullYear()
  // 获得当前月
  const getCurM = getDate.getMonth() + 1
  let setPreY = null // 设置年
  let setPreM = null // 设置月
  switch (getCurM) {
  case 1:
    setPreY = getCurY - 1
    setPreM = 12
    break
  default:
    setPreY = getCurY
    setPreM = getCurM
  }
  cb && cb(setPreY, setPreM)
}

 

二、待续。。。

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-25
  • 2022-01-08
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-07
  • 2021-10-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案