1. (Background: In the past, when performing a system query, you must display the system's current and next day. The current time is easy to write, but not the next day, the following is the one you tried to write .)
Function tomorrow (){
VaR date = new date ();
VaR year = date. getyear (); // obtain the current year command
VaR month = date. getmonth () 1;
VaR day = date. getdate ();
VaR datestr = NULL;
If (Year % 4 = 0 & amp; Year % 100! = 0 | year % 400 = 0) {// This is a leap year.
If (month = 1 | month = 3 | month = 5 | month = 7 | month = 8 | month = 10 ){
If (Day = 31 ){
Month = Month 1;
If (month <10) {month = '0' month ;}
Datestr = year "-" month "-" 01 ";
} Else if (day! = 31 ){
Day = Day 1;
If (month <10) {month = '0' month ;}
If (day <10) {day = '0' day ;}
Datestr = year "-" month "-" Day ;}
} Else if (month = 4 | month = 6 | month = 9 | month = 11 ){
If (Day = 30 ){
Month = Month 1;
If (month <10) {month = '0' month ;}
Datestr = year "-" month "-" 01 ";
} Else if (day! = 30 ){
Day = Day 1;
If (month <10) {month = '0' month ;}
If (day <10) {day = '0' day ;}
Datestr = year "-" month "-" Day ;}
} Else if (month = 12 ){
If (Day = 31) {month = "01"; datestr = year 1 "-" month "-" 01 ";}
Else if (day! = 31 ){
Day = Day 1;
If (month <10) {month = '0' month ;}
If (day <10) {day = '0' day ;}
Datestr = year "-" month "-" Day ;}
} Else if (month = 2 ){
If (Day = 29) {month = "03"; datestr = year "-" month "-" 01 ";}
Else if (day! = 29 ){
Day = Day 1;
If (month <10) {month = '0' month ;}
If (day <10) {day = '0' day ;}
Datestr = year "-" month "-" Day ;}
}
} Else {// non-leap year
If (month = 1 | month = 3 | month = 5 | month = 7 | month = 8 | month = 10 ){
If (Day = 31 ){
Month = Month 1;
If (month <10) {month = '0' month ;}
Datestr = year "-" month "-" 01 ";
} Else if (day! = 31 ){
Day = Day 1;
If (month <10) {month = '0' month ;}
If (day <10) {day = '0' day ;}
Datestr = year "-" month "-" Day ;}
} Else if (month = 4 | month = 6 | month = 9 | month = 11 ){
If (Day = 30 ){
Month = Month 1;
If (month <10) {month = '0' month ;}
Datestr = year "-" month "-" 01 ";
} Else if (day! = 30 ){
Day = Day 1;
If (month <10) {month = '0' month ;}
If (day <10) {day = '0' day ;}
Datestr = year "-" month "-" Day ;}
} Else if (month = 12 ){
If (Day = 31) {month = "01"; datestr = year 1 "-" month "-" 01 ";}
Else if (day! = 31 ){
Day = Day 1;
If (month <10) {month = '0' month ;}
If (day <10) {day = '0' day ;}
Datestr = year "-" month "-" Day ;}
} Else if (month = 2 ){
If (Day = 28) {month = "03"; datestr = year "-" month "-" 01 ";}
Else if (day! = 28 ){
Day = Day 1;
If (month <10) {month = '0' month ;}
If (day <10) {day = '0' day ;}
Datestr = year "-" month "-" Day ;}
}
}
Alert (datestr); // added to view the result
}
2. Self-written features are prone to errors. by calling the built-in functions of JS, the auto-increment of the generated objects can well control the generation of 2008-10-32, undefined, and null.
Function nextdate (){
VaR date = new date ();
VaR B = date. getdate ();
B + = 1;
Date. setdate (B );
VaR year = date. getyear (); // obtain the current year command
VaR month = date. getmonth () + 1;
VaR day = date. getdate ();
If (month <10) {month = '0' + month ;}
If (day <10) {day = '0' + day ;}
VaR datestr = year + "-" + month + "-" + Day;
Alert (datestr );
}