Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

113
Visualizações
jquery-timepicker desable past time

Im using jquery time picker i wanted to disable the past time This is what I have currently

$('.timepicker').timepicker({ 
            'timeFormat': 'h:i A',
            'minTime' : "11:30 am",
            'maxTime' : "02:30 pm",
            'step': '30',
            'disableTimeRanges': [['10am', '11am']]
            
        });

im using https://github.com/jonthornton/jquery-timepicker

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To make the minTime setting dynamic you can determine the current time using new Date(). From there you need to calculate the nearest 30 minute interval (as that's the step you're using). A reference to the function which calculates that date can then be provided to minDate. Try this:

let roundDate = (date = new Date(), roundToMinutes = 30) => {
  const ms = 1000 * 60 * roundToMinutes;
  return new Date(Math.ceil(date.getTime() / ms) * ms);
}

$('.timepicker').timepicker({
  timeFormat: 'h:i A',
  minTime: roundDate,
  maxTime: "02:30 pm",
  step: '30',
  disableTimeRanges: [
    ['10am', '11am']
  ]
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.13.18/jquery.timepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.13.18/jquery.timepicker.min.css" />
<input type="text" class="timepicker" />

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda