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

132
Views
conflicto donde agregar segundo a una fecha en javascript y angular

Estoy tratando de agregar un segundo a una fecha.

lo intento:

 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 = número (segundo).

resp.data.locations[0].stay_limit = número (minuto).

Como vemos, startTime funciona bien al principio, y endTime también, pero:

después de agregar esto:

 this.endTime = new Date(temp.setSeconds(temp.getSeconds() + (resp.data.locations[0].stay_limit * 60)));

this.startTime cambia, y es lo mismo que el valor de endTime.

para solucionar esto, uso temp para almacenar startTime en él para usar temp en endTime, pero tampoco funciona.

la salida debe ser:

 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).

No sé por qué el valor de startTime cambia después de agregar la consulta endTime.

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!