I have a system that calculates the number of days but the problem is that the client wants that the current day I also add them. Example: if I choose today 12-13-2018 at 12-15-2018, it results in 2 days and I have to count 3 days.
script.js
function data(valor){
let ingreso = document.getElementById("ingreso").value;
let retiro = document.getElementById("retiro").value;
let fechaInicio = new Date(ingreso).getTime();
let fechaFin = new Date(retiro).getTime();
let diff = fechaFin - fechaInicio; //Diferencia en milisegundos
let dias = diff/(1000*60*60*24); //Diferencia en dias
document.getElementById("totaldias").value = dias;
document.getElementById("valor").value = dias*valor;
//document.getElementById("dolares").value = valor*tasa_cambio;
}
index.php
<?php
$tarjeta = 200;
$efectivo = $tarjeta*0.5;
?>
<input type="date" name="ingreso" id="ingreso" autocomplete="off">
<input type="date" name="salida" id="retiro" autocomplete="off" onChange="data(<?php echo $tarjeta;?>)">
<input type="text" name="dias" id="totaldias" readonly="readonly">