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

225
Views
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 answers
Answer question

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 Report

0

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

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!