10 examples of 'get current month in javascript' in JavaScript

Every line of 'get current month in javascript' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
179export function getPreviousDisplayMonth(month) {
180 if (month === 0) {
181 return 11;
182 }
183
184 return month - 1;
185}
96public getCurrentDate(): string {
97 /* Return current year(string) to display in calendar header. */
98 return this.state.date.year().toString();
99}
6getMonthName(month) {
7 return this.constructor.static.monthNames[month]
8}
221function _formatMonth(month) {
222 var updatedMonth = month + 1;
223 return _prepandZero(updatedMonth);
224}
140export 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}
178export function formatmonth(d) {
179 if (d) {
180 let month = months.abbr[parseInt(d.slice(4, 6)) - 1]
181 return month + '/' + d.slice(0, 4)
182 }
183}
44function getDaysInMonth(year, month) {
45 return 32 - new Date(UTC(year, month, 32)).getUTCDate();
46};
16function previousMonth(month) {
17 var date = from_iso8601(month),
18 msInDay = 24*60*60*1000,
19 msThisMonth = date.getDate()*msInDay,
20 dateInPreviousMonth = new Date(date - msThisMonth - msInDay);
21
22 return to_iso8601(dateInPreviousMonth).substr(0,7);
23}
119function gotoMonth(year, month) {
120 date = new Date(year, month, 1);
121 refreshMonth();
122}
49export function toShortMonth(month: Month): ShortMonth {
50 return MONTH_SHORTMONTH[month];
51}

Related snippets