SHARE
TWEET

Untitled

a guest Jul 19th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //CALCULAR DIAS
  2.  
  3.     function CalcDias(){
  4.             var data1 = new Date(document.getElementById("data1").value);
  5.             var data2 = new Date(document.getElementById("data2").value);
  6.             return parseInt((data1 - data2) / (24 * 3600 * 1000));
  7.     }
  8.  
  9. //CALCULAR HORAS
  10.  
  11.     function CalcHoras(){
  12.             var data1 = new Date(document.getElementById("data1").value);
  13.             var data2 = new Date(document.getElementById("data2").value);
  14.             return parseInt((data1 - data2) / (24 * 3600 * 1000));
  15.     }
  16.  
  17. //CALCULAR SEGUNDOS
  18.  
  19.    function CalcSegundos(){
  20.             var data1 = new Date(document.getElementById("data1").value);
  21.            var data2 = new Date(document.getElementById("data2").value);
  22.             return parseInt((data1 - data2) / (24 * 3600 * 1000));
  23.     }
  24.  
  25. //MOSTRAR RESULTADOS
  26.  
  27.     function result(){
  28.     if(document.getElementById("data1")){
  29.         document.getElementById("result_dias").value=CalcDias();
  30.         document.getElementById("result_horas").value=CalcHoras();
  31.         document.getElementById("result_segundos").value=CalcSegundos();
  32.  
  33.     }  
  34. }
  35.  
  36. </script>
  37.      
  38. <div id="pickup_date"><p><label class="form">Primeira data:</label><input type="date" class="textbox" id="data2" name="data_2" onchange="result()"/></p></div>
  39.  
  40. <div id="dropoff_date"><p><label class="form">Segunda data:</label><input type="date" class="textbox" id="data1" name="data_1" onchange="result()"/></p></div>
  41.  
  42. <div id="numdays"><label class="form">Diferen├ža em Dias:</label><input type="text" class="textbox" id="result_dias" name="dias"/></div>
  43. <br/>
  44. </div>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top