/** * 获取当前月的第一天 */function getCurrentMonthFirst(){ var date=new Date(); date.setDate(1); return date;}/** * 获取当前月的最后一天 */function getCurrentMonthLast(){ var date=new Date(); var currentMonth=date.getMonth(); var nextMonth=++currentMonth; var nextMont
public class CalendarTest { public static void main(String[] args) { // 获取当前年份.月份.日期 Calendar cale = null; cale = Calendar.getInstance(); int year = cale.get(Calendar.YEAR); int month = cale.get(Calendar.MONTH) + 1; int day = cale.get(Calendar.DATE);
1. 概述 1.1 说明 在项目过程中,有时候需要默认展示一个月的查询条件,即当月的第一天和最后一天. 2. 代码 2.1 代码示例 直接调用getFirstAndLastDay()即可得到当月的第一天和最后一天. /** * 获取当前月份的第一天和最后一天 **/ function getFirstAndLastDay() { let now = new Date(); let strLink = "-"; let year = now.getFullYear(); let mont
var nowdays = new Date(); var year = nowdays.getFullYear(); var month = nowdays.getMonth(); if(month==0){ month = 12; year = year-1; } if(month<10){ month = '0'+month; } var myDate = new Date(year,month,0); var startDate = year+'-'+month+'-01 00:00:0