So I have one input with date+time value (getting values from DB) and I am using jQuery Datetime picker to change date/time.
Here is my input
<div class="input-group form-group td-350">
<div class="input-group date" id="datetimepicker1">
<input type="text" name="new_preffered_date" class="form-control datetimepickers" value="<?= $item->customer_preferred_date->i18nFormat('dd.MM.YYYY HH:mm', 'Europe/Vienna') ?>"/>
<span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span>
</div>
</div>
And here is my Datetimepicker configuration:
<script type="text/javascript" src="/vendors/bower_components/moment/min/moment-with-locales.js"></script>
<script type="text/javascript" src="/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript">
$('.datetimepickers').each(function () {
$(this).datetimepicker({
daysOfWeekDisabled: [0, 6],
format: 'DD.MM.YYYY HH:mm',
locale: 'de',
minDate: new Date(),
});
});
</script>
With this configuration, Datetimepicker take as default value always date time from now. If I delete daysOfWeekDisabled
option than I can see real date/time from database in input.
Info: My date from database is not weekend and is newer as now().
So my question is, how can I use DateTime picker with daysOfWeekDisabled
option and as default value show date from database?
Documentation of Datetime picker is http://eonasdan.github.io/bootstrap-datetimepicker/Options/#daysofweekdisabled
Set the useCurrent
property to false
. It will set the picker to the selected date/time instead of current.