const myTimeout = setTimeout(kill_session,900000); function kill_session() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } location.reload(); xmlhttp.open("GET","model/logout.php",false); xmlhttp.send(); // document.getElementById("id_of_a_hidden_div").innerHTML=xmlhttp.responseText; } function time_loader() { setInterval(function() { var date = new Date(); var day = ("0" + (date.getDate())).slice(-2); var mon = ("0" + (date.getMonth() + 1)).slice(-2); var year = date.getFullYear(); var hours = ("0" + (date.getHours())).slice(-2); var minute = ("0" + (date.getMinutes())).slice(-2); var seconds = ("0" + (date.getSeconds())).slice(-2); if (hours == 07 && minute == 00 && seconds >= 00) { localStorage.clear(); localStorage.clickcount = 0; location.reload(); } var num = Number(localStorage.clickcount)+1; document.getElementById("codepasien").value = year+''+mon + '' +day+ '' + num; }, 1000); } function getDateDiffInYMD(startDate, endDate) { const oneDayMs = 1000 * 60 * 60 * 24; const diffMs = endDate.getTime() - startDate.getTime(); const diffDays = Math.floor(diffMs / oneDayMs); const tahun = Math.floor(diffDays / 365); const bulan = Math.floor(diffDays / 30.44) % 12; const hari = diffDays - (tahun * 365) - (Math.floor(bulan * 30.44)); return { tahun, bulan, hari }; } var born = document.getElementById('inputumur').value; const startDate = new Date('1963-06-19'); const endDate = new Date(); const diff = getDateDiffInYMD(startDate, endDate); console.log(diff); // { tahun: 1, bulan: 2, hari: 26 } console.log(born);