首页 > 其他 > 详细

一些有关时间的获取

时间:2021-01-11 12:01:08      阅读:23      评论:0      收藏:0      [点我收藏+]

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

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

 

二、待续。。。

 

一些有关时间的获取

原文:https://www.cnblogs.com/waitingbar/p/14260942.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!