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

185
Views
Establezca la hora y los minutos en la selección del día usando el complemento jquery datetimepicker

Estoy tratando de establecer el tiempo usando variables usando jquery datetimepicker. Entonces, el problema es el siguiente: en mi lógica, tengo un selector de fecha y hora que puede seleccionar la fecha y la hora. Cuando el usuario hace clic en el campo del formulario y selecciona solo la fecha, el complemento establece la fecha seleccionada y la hora actual. Pero tenemos diferentes horarios disponibles establecidos por código (por ejemplo: lunes de 9:00 a 12:00 (hora de paso 1), martes de 8:00 a 11:00). Entonces, el selector no tiene que establecer la hora actual, sino la primera hora disponible, por ejemplo, 9:00 para el lunes.

Cuando selecciono solo la fecha, también establece la hora (pero está mal porque en este caso solo tenemos las 9:00 de la mañana), por lo que el resultado debería ser: 2022/04/01 09:00

esto es cuando selecciono el día

¿Cómo puedo configurarlo? Debajo de un ejemplo de código:

Selector de fecha y hora (jquery):

 /** * @param currentDateTime {Date} */ const allowTimeOnSelectedDay = function (currentDateTime) { if (currentDateTime != null) { var currentDay = currentDateTime.getDay(); const map1 = data.week.map(el => { if (el.day == currentDay) { let allowedTimes = generateAllowedTime(el.startingMattina, el.closingMattina, el.startingPome, el.closingPome); console.log(allowedTimes); console.log(allowedTimes[0]); this.setOptions({ allowTimes: allowedTimes }); } }); } }; $('#datetimepicker11').datetimepicker({ dayOfWeekStart: 1, formatDate: 'd/m/YH:i', minDate: dateToStart, maxDate: new Date(Date.parse(data.endDate)), startDate: dateToStart, beforeShowDay: function (date) { for (let i = 0; i < arr.length; i++) { if (date.getMonth() == arr[i].getMonth() && date.getDate() == arr[i].getDate()) { return [false, ""] } } return [true, ""]; }, onChangeDateTime: allowTimeOnSelectedDay, onShow: allowTimeOnSelectedDay, //onSelectDate : formattedDateOnSelectedDateOnly, });
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!