Hy ! I have 3 variables in database login_time, logout_time, total_time. The datatype of total_time is 'time' while the other two have 'date_time' datatype. What i did, I extract only login_time and logout_time in query and saved them into variables. I have login and logout time stored in variables. Now i need to calculate total time in Hours, min, second. I tried to calculate but it does not give exact time like this.
login_time = 2016-03-21 14:09:28
logout_time = 2016-03-21 14:10:22
total_time = 11:50:32
That's wrong ! What's my mistake ?
I tried many solutions but they did not resolved my problem ! Help me
if(isset($_SESSION['start_time']))
{
$start = $_SESSION['start_time'];
$final = $_SESSION['final_time'];
$diff = strtotime($final) - strtotime($start);
//"%H:%M:%S"
$total = date('H:i:s', $diff);
$sql4 = "UPDATE log SET total_time = '$total' WHERE username = '$user'";
$res4 = mysqli_query($link, $sql4);