Detect page visit duration
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js" />
<script>
function viewstatistics() {
var time = 0;
//var x = document.getElementById("description");
document.getElementById("accessdate").innerHTML = new Date();
setInterval(function() {
if (document.hasFocus()) {
time++;
$("#downtime").html(time);
}
}, 1000);
}
</script>