Con JavaScript o con Ajax
Necesito ingresar la fecha de inicio con la hora de inicio y la fecha de finalización con la hora de finalización. Y cree cuatro casillas de verificación para cada día del rango de fechas seleccionado, en línea con la fecha mencionada al frente.
PERO la última casilla de verificación del último raw no debe ser seleccionable/clic SI no es un día completo con 24 horas en su totalidad. Lo que significa que si la diferencia entre dos tiempos ingresados es menor a 1 minuto.
Por favor ayuda. Es complicado para mi.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.1/moment.min.js"></script> <strong>Start</strong> <br>Date: <input id="fromDate" type='date' /> Time: <input type="time" id="start-time" placeholder="HH:MM"> <br><br><br> <strong>End</strong> <br>Date: <input id="toDate" type='date' /> Time: <input type="time" id="end-time" placeholder="HH:MM"> <button id="btn">Submit</button><hr /> <p id="result"></p> <script> $("#btn").on('click', function(e) { var fromDate = $('#fromDate').val(), toDate = $('#toDate').val(), from, to, druation; from = moment(fromDate, 'YYYY-MM-DD'); // format in which you have the date to = moment(toDate, 'YYYY-MM-DD'); // format in which you have the date /* using diff */ duration = to.diff(from, 'days') /* show the result */ $('#result').text(duration + ' days'); }); </script> <br> <input type="text" id="total-hours" placeholder="Total Hours"> <script> document.querySelector("#end-time").addEventListener("change", myFunction); function myFunction() { function split(time) { var t = time.split(":"); return parseInt((t[0] * 60), 10) + parseInt(t[1], 10); //convert to minutes and add minutes } //value start var start = split($("input#start-time").val()); //format HH:MM //value end var end = split($("input#end-time").val()); //format HH:MM totalHours = NaN; if (start < end) { totalHours = Math.floor((end-start)/60); } $("#total-hours").val(totalHours); } </script>