[Java]
Date. prototype. format = function (){
Var s = '';
S + = this. getFullYear () + '-'; // obtain the year.
S + = (this. getMonth () + 1) + "-"; // obtain the month.
S + = this. getDate (); // get the day.
Return (s); // return the date.
};
Function getAll (){
Var begin = $ (": input [name = from]"). val ();
Var end = $ (": input [name = to]"). val ();
Var AB = begin. split ("-");
Var AE = end. split ("-");
Var db = new Date ();
Db. setUTCFullYear (AB [0], AB [1]-1, AB [2]);
Var de = new Date ();
De. setUTCFullYear (AE [0], AE [1]-1, AE [2]);
Var unixDb = db. getTime ();
Var unixDe = de. getTime ();
Var n = 1;
For (var k = unixDb; k <unixDe ;){
// Alert (new Date (parseInt (k). format (); // The yyyy-MM-dd format of the current day
If (n> 30 ){
Ext. Msg. alert ("prompt", "check-in date is greater than 30 days, cannot be reserved ");
Return false;
}
N = n + 1;
K = k + 24*60*60*1000;
}
}
My requirement is that the number of days between two dates cannot be greater than 30. The last day is not calculated. This algorithm is between two dates, but does not include the start and end dates. So I accumulate from 1.