I am trying to add 12 days to a specific date. but I am getting the new date as not expected. Here is my code
addDays(days: number): any {
let startDate = new Date(this.selectedDeliveryDate);
let endDate = new Date();
endDate = new Date(startDate.setDate(startDate.getDate() + days))
console.log(startDate, endDate, days)
}
this.selectedDeliveryDate = Wed Dec 08 2021 05:30:00 GMT+0530 (India Standard Time)
and
days = 12
I am getting the endDate
as Tue Feb 20 2024 17:49:13 GMT+0530 (India Standard Time)
EDIT I have printed the following code to test
console.log((startDate.getDate() + days));
and selected 07-12-2021
as start date
and days
is 12
. I am getting the result like 712
. Its just appending the number of days to the day.