6

I'm using the date time picker component from http://trentrichardson.com/examples/timepicker/. Trying to hide the time picker but my code doesn't work:

$('#id_start_date_time').datetimepicker('option', 'showTimepicker', false);
Ruben
  • 925
  • 4
  • 14
  • 35

7 Answers7

7

I just came across this issue. I know its been a while since this question was asked by the OP and he has probably solved the problem. Just for someone who might be encountering this issue in the future, if you want to hide the timepicker, just simply call the original jquery ui datepicker method

datepicker()

instead of

datetimepicker()
Andrew Liu
  • 2,238
  • 4
  • 19
  • 29
5

i use my this code when another code not work.

    $('#datetimepicker_date_to_view').datetimepicker({
            timepicker:false,
            format:'d.m.Y',
        }).on('change', function() {
            $('.xdsoft_datetimepicker').hide();
            var str = $(this).val();
            str = str.split(".");
            $('#alt_date_field').val(str[2]+'-'+str[1]+'-'+str[0]);
        });


<input type="hidden" id="alt_date_field">
Sandeep Sherpur
  • 1,507
  • 18
  • 18
4

timepicker:false for jquery.datetimepicker

Miles
  • 103
  • 7
3

You need to add the following option :

timepicker: false

(timepicker have to be in lowercase)

Romain R
  • 41
  • 4
1

You must define options like this:

$('#id_start_date_time').datetimepicker({
    showTimePicker: false
});

To add more options you can just separate by commas:

$('#id_start_date_time').datetimepicker({
    showTimePicker: false,
    showSecond: true,
    timeFormat: 'hh:mm:ss'
});
peacemaker
  • 2,493
  • 3
  • 24
  • 47
  • I mean the problem is not when creating but when editing the options. Sometimes I want this component to be a datepicker, sometimes a datetimepicker, according some events. – Ruben Jul 30 '12 at 10:40
0

I used the 'showTimepicker': true, / 'showTimepicker': false, options to show / hide the time options if not needed.

some pages have both with time and without time options that is why i needed to use this option.

when i have this set to false, it hides the time options as it is designed to do but the overide

$.datepicker._base_gotoToday = $.datepicker._gotoToday;

causes problems. When i click on today / now button, it sets date to today but hides the calender, and when i click on the input box again nothing happens, only when i click anywhere else then and then click on the input box again does the calender show.

I have removed the line

$('.ui-datepicker-today', $dp).click();

which seems to have solved the problem.

It has lost the ability to close when i click the today button but i can live with that

Shaakir
  • 394
  • 4
  • 12
0

this code working fine:

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.min.css">
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.min.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.full.min.js"></script>


<input class="form-control" id="datetimepicker" type="text" name="date" placeholder="Date">

<script>
$('#datetimepicker').datetimepicker({
    format:'Y-m-d',timepicker: false,
});
</script>

Also,Include jquery library

abhishek kumar
  • 339
  • 2
  • 6