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

// 获取上一个月的年月
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)
}

 

二、待续。。。

 

posted on 2021-01-11 10:27  小老虎网络  阅读(76)  评论(0编辑  收藏  举报