//月份值范围0-11, 天值从1开始,月份填-1代表上月,天值写0就自动跳上月最后一天
var now = new Date();var month = now.getMonth();var year = now.getFullYear();
//本月第一天和最后一天
var first = new Date(year, month, 1); var last = new Date(year, month+1, 0);
//上月第一天和最后一天
var prev_first = new Date(year, month-1, 1);var prev_last = new Date(year, month, 0);
//下月第一天的最后一天
var next_first = new Date(year, month+1, 1);var next_last = new Date(year, month+2, 0);
Date.format():javascript Date format(js日期格式化) - 一路前行 - 博客园