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

226
Views
Cómo fusionar fecha y hora usando Javascript

Soy nuevo en JavaScript y no sé mucho. Sé que ya hay muchas preguntas similares disponibles, pero no obtuve lo que estaba buscando. Tengo 2 entradas, una es datePicker y la otra es timePicker.

 <form> <div class="form-group"> <label for="a">Date :</label> <input class="form-control" ng-model="res.Date" ng-required="true" type="date" > </div> <div class="form-group"> <label for="a">Time :</label> <input class="form-control timepicker" ng-model="res.Time" ng-required="true" type="time"> </div> </form>

Obtengo la fecha y la hora por separado y en un formato diferente: convertí la fecha en formato aaaa/mm/dd y también formateé la hora con el siguiente código:

 var timeString = $scope.res.Time.getHours() + ':' + $scope.res.Time.getMinutes() + ':00'; var d = new Date($scope.res.Date), month = '' + (d.getMonth() + 1), day = '' + d.getDate(), year = d.getFullYear(); if (month.length < 2) month = '0' + month; if (day.length < 2) day = '0' + day; var fdate = [year, month, day].join('-')

Estoy obteniendo fecha y hora como -

 Time = 20:42:00 Date = 2021-08-11

Pero ahora quiero unirme a ellos y quiero hacerlo así = 2021-08-10T01:01:55.216Z

Probé algunas cosas como el análisis, pero eso no me dio este formato. Perdón por los errores. Por favor, ayúdame a conseguir esto. Gracias

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

 let time = "20:42:00"; let date = new Date("2021-08-11"); let parsedDate = new Date(Date.parse(date.toDateString() + ' ' + time)); console.log(parsedDate.toISOString());

about 4 years ago · Juan Pablo Isaza Report
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!