I have already added minutes and seconds. But I don’t know how to add hours to this. Can any one help me. I have given the all files of ine.This is my index.php file .
<div id="response"> </div>
<script type="text/javascript">
var obj = setInterval(function(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET" , "response.php" , false);
xmlhttp.send(null);
document.getElementById("response").innerHTML =xmlhttp.responseText;
},1000);
</script>
This is my first.php file.
<?php
include("databaseconn.php");
session_start();
$duration = "";
$selectnewtimmer = "SELECT * FROM examinformation";
$res = mysqli_query($conn, $selectnewtimmer);
$row = mysqli_fetch_assoc($res);
$duration = $row['minutesnew'];
$hoursnew = $row['hoursnew'];
$_SESSION['hoursnew'] = $hoursnew;
$_SESSION['duration'] = $duration;
$_SESSION['start_time'] = date("Y-m-d H:i:s");
$endTime = date('Y-m-d H:i:s', strtotime('+'.$_SESSION['hoursnew']. 'hours' . $_SESSION['duration'] . 'minutes', strtotime($_SESSION['start_time'])));
$_SESSION['endTime'] = $endTime;
?>
<script type="text/javascript">
window.
location="questions.php";
</script>
This is my ‘response.php’ file
<?php
session_start();
$form_time1 = date('Y-m-d H:i:s');
$to_time1 = $_SESSION['endTime'];
$timefirst = strtotime($form_time1);
$timeseconds = strtotime($to_time1);
$diffecrceinseconds = $timeseconds - $timefirst;
echo gmdate("H:i:s" , $diffecrceinseconds);
?>