My goal is to update a date variable called EndDate
stored in localStorage by adding exactly 24 hours to it. The current value in the localStorage is Sun Jun 09 2019 20:39:44 GMT+0530 (India Standard Time).
var endDate = new Date();
endDate.setDate(new Date(localStorage.getItem("requestDate")).getDate() + 1);
When I tried running this code, the result was Mon Jun 10 2019 07:58:50 GMT+0530 (India Standard Time), which is incorrect due to the current datetime being added.
var endDate = new Date();
endDate.setDate(new Date(localStorage.getItem("requestDate")).getDate() + 1);
// Perform necessary operations
endDate.setTime(new Date(localStorage.getItem("requestDate")).getTime() + 24);
Upon trying the above code, the output reverted back to Sun Jun 09 2019 20:39:44 GMT+0530 (India Standard Time) as setTime overwrote the previous date value.
The Desired Output should be Mon Jun 10 2019 20:39:44 GMT+0530 (India Standard Time)