Starting from the current month, when the previous month is used, the calculation factor is 12. When the value is reduced by 1 and 0, the year is reduced by 1, the month is restored to 12, and then pushed back;
Starting from the current month, when the next month is used, the calculation factor is 12. If the value is 1 and the value is 13, the year is added to 1, the month is restored to 12, and then pushed forward.
<SCRIPT type = "text/JavaScript"> // gets the collection of historical months based on the current month (from the current month before the push: History) function complementhistorydate (nummonth) {var compldate = []; var curdate = new date (); var y = curdate. getfullyear (); var M = curdate. getmonth () + 1; // load the current month for the first time (Format: yyyy-mm) compldate [0] = Y + "-" + (M. tostring (). length = 1? "0" + M: m); m --; // It has been loaded for the first time. nummonth is calculated once less than once for (VAR I = 1; I <nummonth; I ++, m --) {If (M = 0) {// one year later, y --; M = 12; // push back from March 13, December} compldate [I] = Y + "-" + (M. tostring (). length = 1? "0" + M: m);} return compldate;} // obtain the collection of future months based on the current month (from the current month to the future) function complementfuturedate (nummonth) {var compldate = []; var curdate = new date (); var y = curdate. getfullyear (); var M = curdate. getmonth () + 1; // load the current month for the first time (Format: yyyy-mm) compldate [0] = Y + "-" + (M. tostring (). length = 1? "0" + M: m); m ++; // It has been loaded for the first time. nummonth is calculated once less than once for (VAR I = 1; I <nummonth; I ++, M ++) {If (M = 13) {// one year later than January 1, December, y ++; M = 1; // push forward from March 13, January} compldate [I] = Y + "-" + (M. tostring (). length = 1? "0" + M: m);} return compldate ;}</SCRIPT>