I have these two fields of date type, which I use to establish a period of dates
<div class="form-group">
<div class="input-group date" id="datetimepicker1">
<input id="fechInicio" name="fechInicio" class="form-control" type="text"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<div class="form-group">
<div class="input-group date" id="datetimepicker2">
<input id="fechFin" name="fechFin" class="form-control" type="text"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
What I want to do is that in the datetimepicker2 when loading the default page, have the date of the current day and that the date can not be selected one day after the current day, and that in the datetimepicker1 only dates can be chosen of a bimester back of the current date.
How can I do that?
I only have this code that initializes
function validaFechas(){
$('datetimepicker1').datetimepicker({
locale: 'es',
format: 'L',
useCurrent: true,
format: 'DD/MM/YYYY'
});
$('datetimepicker2').datetimepicker({
locale: 'es',
format: 'L',
useCurrent: true,
format: 'DD/MM/YYYY'
});
$("#datetimepicker1").on("dp.change",function (e){
var fechaInicio = new Date(e.date);
$('#datetimepicker2').data("DateTimePicker").minDate(e.date);
var maximaFechaFin = new Date();
maximaFechaFin.setMinutes(1);
$('#datetimepicker2').data("DateTimePicker").maxDate(maximaFechaFin);
});
$("#datetimepicker2").on("dp.change",function (e)
{
$('#datetimepicker1').data("DateTimePicker").maxDate(e.date);
var maximaFechaInicio = new Date();
var minimoFechaInicio = new Date(maximaFechaInicio.getFullYear(),
maximaFechaInicio.getMonth(), maximaFechaInicio.getDate() -92);
$('#datetimepicker1').data("DateTimePicker").minDate(minimoFechaInicio);
});
}