Day to exhibit, add year, month, and day. [time required to set to latest]

Source: Internet
Author: User

 

/* ************************************
** Name: addmonths ()**
** Function: Add a specified month to a date **
** Number of months: the sum of the number of months [int] **
** Return: date after addition **
************************************ */
Date. Prototype. addmonths = Function (Months ){
VaR Year = Parseint ( This . Getfullyear ());
VaR Month = Parseint ( This . Getmonth ()); // [0-11]
// The number of months is greater than 12.
If (Months > 11 ){
Year = Year + Months / 12;
Months = Months % 12 ;
}
If (Month + Months) > 11 ){
Year = Year + (Month + Months) / 12;
Month = (Month + Months) % 12 ;
} Else {
Month = Month + Months;
}
This . Setfullyear (year );
This . Setmonth (month );
Return   This ;
}
/* ************************************
** Region: adddays ()**
** Function: add the specified number of days to the date **
** Metric data: months: Sum up the number of days [int] **
** Return: date after addition **
************************************ */
Date. Prototype. adddays = Function (Days ){
VaR Day = Parseint ( This . Getdate ());
Day + = Days;
This . Setdate (day );
Return   This ;
}
/* ************************************
** Name: addyears ()**
** Function: Add a specified year to the date **
** Metric data: months: Sum year data [int] **
** Return: date after addition **
************************************ */
Date. Prototype. addyears = Function (Years ){
VaR Year = Parseint ( This . Getfullyear ());
Year + = Years;
This . Setfullyear (year );
Return   This ;
}

 

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.