js获取从上月一整月,本月1号到今天的日期

js获取从上月一整月日期

js获取从本月1号到今天的日期
  const start = new Date()
 start.setTime(new Date(new Date().getFullYear(), new Date().getMonth(), 1)) 
 本月一号

获取上个月一整个月日期
     const end = new Date()
      const start = new Date()
      var day = new Date(start.getFullYear(), start.getMonth(), 0).getDate()
 start.setTime(new Date(new Date().getFullYear(), new Date().getMonth() - 1, 1))
      end.setTime(new Date(new Date().getFullYear(), new Date().getMonth() - 1, day))

猜你喜欢

转载自blog.csdn.net/qq_28008615/article/details/82863782
今日推荐