How to calculate time in php

Hi All I'm trying to calculate elapsed time in php. The problem is not in php, it's with my mathematical skills. For instance: Time In: 11:35:20 [hh:mm:ss], now say the current time is: 12:00:45 [hh:mm:ss] then the time difference in my formula gives the output: 1:-34:25. It should actually be: 25:25

$d1=getdate[];
$hournew=$d1['hours'];
$minnew=$d1['minutes'];
$secnew=$d1['seconds'];

$hourin = $_SESSION['h'];
$secin = $_SESSION['s'];
$minin = $_SESSION['m'];

$h2=$hournew-$hourin;
$s1=$secnew-$secin;
$m1=$minnew-$minin;

if[$s1=[60-$secin]] {
    $m1--;  }
if[$m1

Chủ Đề