[Javascript] // obtain functiongetLastDay (year, month) {varnew_yearyear; // obtain the current year varnew_monthmonth ++; // obtain the first day of the next month, easy to calculate (not fixed on the last day) if (mont... syntaxH [javascript]
// Obtain the last day of a month
Function getLastDay (year, month ){
Var new_year = year; // returns the current year.
Var new_month = month ++; // obtain the first day of the next month for easy calculation (the last day is not fixed)
If (month> 12 ){
New_month-= 12; // month minus
New_year ++; // year increase
}
Var new_date = new Date (new_year, new_month, 1); // obtain the first day of the current month.
Return (new Date (new_date.getTime ()-1000*60*60*24). getDate (); // obtain the Date of the last day of the month
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service