Get the last day of the current month
The source code for the method that directly on JavaScript gets the last day of the month:
| The code is as follows |
Copy Code |
|
/**
* Get the last day of the current month
*/
function Getcurrentmonthlast () {
var date=new date ();
var currentmonth=date.getmonth ();
var nextmonth=++currentmonth;
var nextmonthfirstday=new Date (Date.getfullyear (), nextmonth,1);
var oneday=1000*60*60*24;
return new Date (Nextmonthfirstday-oneday);
} |
function returns a date-type value that can be used to calculate a date or format the output.
Get the first day of the current month
Directly on JavaScript gets the source code for the first day of the month:
| The code is as follows |
Copy Code |
|
/**
* Get the first day of the current month
*/
function Getcurrentmonthfirst () {
var date=new date ();
Date.setdate (1);
return date;
} |
function returns a date-type value that can be used to calculate a date or format the output.