js拿到本月初日期,拿到上个月的日期(上个月的同一天)

来源:互联网 发布:漫威电影宇宙知乎 编辑:程序博客网 时间:2024/05/18 11:08

拿到本月初日期:

var today = new Date();var days = date1.getDate()-1;var beginOfMonth = addDay(date1, -days);    var endDate = formatDate(beginOfMonth,"yyyyMMdd");var endDate = formatDate(today,"yyyyMMdd");

拿到上个月的日期(上个月的同一天) 
var lastMonthDate = new Date(); //上月日期  var days = lastMonthDate.getDate();lastMonthDate.setDate(days);  lastMonthDate.setMonth(lastMonthDate.getMonth()-1);


0 0
原创粉丝点击