获取上个月

2018-09-12  本文已影响0人  zackxizi
function getPreDate () {
  const toDate = new Date()
  const preDay = toDate - 24 * 60 * 60 * 1000
  const preDate = new Date(preDay)
  return `${preDate.getFullYear()}-${(preDate.getMonth() + 1) > 9 ? preDate.getMonth() + 1 : '0' + (preDate.getMonth() + 1)}-${(preDate.getDate()) > 9 ? preDate.getDate() : '0' + (preDate.getDate())}`
}
上一篇 下一篇

猜你喜欢

热点阅读