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

232
Visualizações
How to change the bootstrap datetimepicker to display only dates and not time

I have several inputs with dates. I don't need time, but somehow I can't get rid of it.

I tried all the solutions I found on StackOverflow without success.

I am using the tempusdominus datetimepicker.

JS FIDDLE LIVE DEMO

Does anyone know how can I remove the option to enter hours and minutes?

I thought format: 'MM/DD/YYYY' would do the trick but apparently it's not working.

$('#monthDatetimepicker').datetimepicker({
            defaultDate: date,
            viewMode: 'days',
            format: 'MM/DD/YYYY'
        });
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You need to set the default options so that it applies to newly created date[time]pickers:

From the options page on how to set global defaults:

  $.fn.datetimepicker.Constructor.Default = $.extend({}, $.fn.datetimepicker.Constructor.Default, {
    viewMode: 'days',
    format: 'MM/DD/YYYY',
  });

Updated fiddle


Your issue was that this line

$('#monthDatetimepicker').datetimepicker({
    format: 'MM/dd/YYYY'

doesn't get applied to anything as $('#monthDatetimepicker') === 0 at the time the code runs.

Moving that line to the end also does nothing as your newly created date inputs have id="monthDatetimepicker" + i. Changing to a valid ID such as:

$('#monthDatetimepicker0').datetimepicker({
    format: 'MM/dd/YYYY'

then only works for the first picker.

So you could do some hideous $("[id=^monthDatetimepicker]").datetimepicker... or, easier, you could add a class into your html builder and use that as a selector. Or set it globally as above (which will affect other pickers unless they had a different format applied). (or use a datepicker instead...)

about 4 years ago · Juan Pablo Isaza Relatório

0

Add .substring(0,10) at the end.

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