Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda