Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
conflit where adding second to a Date in javascript and angular

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!