I'm facing an issue where I need to add 12 days to a specific date, but the new date is not coming out as expected. Below is the code snippet:
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
The endDate
is being returned as Tue Feb 20 2024 17:49:13 GMT+0530 (India Standard Time)
EDIT I have also tested the following code snippet:
console.log((startDate.getDate() + days));
With 07-12-2021
selected as the start date
and 12
set for days
, the result obtained was 712
. It seems like the number of days is just getting appended to the day value.