So if you find this type of problem in the future, you can check whether the time zone does not match.
The Code is as follows:
// DateObj is a date object. days indicates how many days are added to the date, for example, 4 or 5 days)
Function dateAdd (dateObj, days ){
Var tempDate = dateObj. valueOf ();
TempDate = tempDate + days * 24*60*60*1000;
TempDate = new Date (tempDate );
Return tempDate;
}
// Create a date object.
Var dateValue = document. getElementById ("XXYY"). value. split ("-");
Var custArvDateTwoValue = new Date (dateValue [0], dateValue [1]-1, dateValue [2]);
// Call dateAdd and add two days
CustArvDateTwoValue = dateAdd (custArvDateTwoValue, 2 );
Var year = custArvDateTwoValue. getFullYear ();
Var month = custArvDateTwoValue. getMonth () + 1;
Var days = custArvDateTwoValue. getDate ();
Month = month <= 9? "0" + month: month;
Days = days <= 9? "0" + days: days;
Document. getElementById ("XX"). value = year + "-" + month + "-" + days;
During the test, I found that when document. getElementById ("XXYY"). value is
The returned result is.
All other situations are correct. For example, enter 2009-10-01 and return 2009-1003.
I also tried today and next year's last day of each month, and there was only a problem in (I tried a lot of time, only this time there was a problem, the difficulty of this month has 32 days)
When I try, the returned result is.
At last, we found that it was a problem with the time zone, so we will find this problem in the future. You can check whether the time zone does not match.