Every line of 'js get current month' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
64 function endofmonth() { 65 var curr = new Date; // get current date 66 var lastday = new Date(curr.setDate(30)); 67 var result = lastday.getFullYear()+"-"+(lastday.getMonth() + 1) + "-" 68 + lastday.getDate(); 69 return result; 70 }
149 function nextMonth() { 150 calendar.selectedDate.setMonth(calendar.selectedDate.getMonth() + 1); 151 calendar.selectedDate.setDate(1); 152 153 setMonth({date: calendar.selectedDate}); 154 155 getEventsForMonth(); 156 }
179 export function getPreviousDisplayMonth(month) { 180 if (month === 0) { 181 return 11; 182 } 183 184 return month - 1; 185 }
140 export function getMonth(date: Date): CalendarMonthTimeRange { 141 const start = new Date(date) 142 start.setDate(1) 143 start.setHours(0, 0, 0, 0) 144 const end = new Date(start) 145 end.setMonth(start.getMonth() + 1) 146 return {start, end} 147 }
96 function getDaysInMonth(d) { 97 var resultDate = getFirstDayOfMonth(d); 98 resultDate.setMonth(resultDate.getMonth() + 1); 99 resultDate.setDate(resultDate.getDate() - 1); 100 return resultDate.getDate(); 101 }
42 export function getDaysInMonth (d) { 43 const resultDate = getFirstDayOfMonth(d); 44 45 resultDate.setMonth(resultDate.getMonth() + 1); 46 resultDate.setDate(resultDate.getDate() - 1); 47 48 return resultDate.getDate(); 49 }
156 getDates(month, startFromMonday) { 157 month = new Date(month); 158 month.setDate(1); 159 160 var delta = month.getDay(); 161 if (startFromMonday) { 162 delta--; 163 if (delta === -1) delta = 6; 164 } 165 166 var startDate = new Date(month); 167 startDate.setDate(startDate.getDate() - delta); 168 169 month.setMonth(month.getMonth() + 1); 170 month.setDate(0); 171 172 delta = 6 - month.getDay(); 173 if (startFromMonday) { 174 delta++; 175 if (delta === 7) delta = 0; 176 } 177 178 var lastDate = new Date(month); 179 lastDate.setDate(lastDate.getDate() + delta); 180 181 var allDates = []; 182 while (startDate <= lastDate) { 183 allDates.push(new Date(startDate)); 184 startDate.setDate(startDate.getDate() + 1); 185 } 186 return allDates; 187 }
44 function getDaysInMonth(year, month) { 45 return 32 - new Date(UTC(year, month, 32)).getUTCDate(); 46 };
1 function make_month_calendar(year, month) { 2 var last_day = days_in_month(year, month); 3 4 var first_weekday = get_weekday({year:year, month:month, day:1}); 5 6 var cal = []; 7 var row, col, day; 8 for (row = 0, day = -first_weekday+1; row < 5; row++) { 9 cal[row] = []; 10 for (col = 0; col < 7; col++, day++) { 11 if (day < 1 || day > last_day) { 12 cal[row][col] = null; 13 } else { 14 cal[row][col] = day; 15 } 16 } 17 } 18 return cal; 19 }
96 public getCurrentDate(): string { 97 /* Return current year(string) to display in calendar header. */ 98 return this.state.date.year().toString(); 99 }