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);
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);
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()
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">
You need to add the following option :
timepicker: false
(timepicker have to be in lowercase)
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'
});
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
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