i am trying to add second to a date.
i try:
var g = this.endTime;
console.log(g); // output : Wed Sep 15 2021 15:35:00 GMT+0300 (Eastern European Summer Time)
this.endTime = null;
this.startTime = null;
this.startTime = new Date(g.setSeconds(g.getSeconds() + this.timeFromGoogle));
console.log(this.startTime); // output: Wed Sep 15 2021 15:42:57 GMT+0300 (Eastern European Summer Time)
var temp = this.startTime;
console.log(temp); // output: Wed Sep 15 2021 15:42:57 GMT+0300 (Eastern European Summer Time)
this.endTime = new Date(temp.setSeconds(temp.getSeconds() + (resp.data.locations[0].stay_limit * 60)));
console.log(this.endTime); // output: Wed Sep 15 2021 15:45:57 GMT+0300 (Eastern European Summer Time)
console.log(this.startTime); // output: Wed Sep 15 2021 15:45:57 GMT+0300 (Eastern European Summer Time)
console.log(temp); // output : Wed Sep 15 2021 15:45:57 GMT+0300 (Eastern European Summer Time)
this.timeFromGoogle = number (second).
resp.data.locations[0].stay_limit = number(minute).
As we see startTime work fine in begining, and endTime also but:
after adding this:
this.endTime = new Date(temp.setSeconds(temp.getSeconds() + (resp.data.locations[0].stay_limit * 60)));
this.startTime change, and his same as endTime value.
to fix this i use temp to store startTime on it to use temp in endTime, but also not work.
output should be:
startTime: Wed Sep 15 2021 15:42:57 GMT+0300 (Eastern European Summer Time).
endTime: Wed Sep 15 2021 15:45:57 GMT+0300 (Eastern European Summer Time).
i don't know why value of startTime change after adding endTime query?