Page 1 of 1

calculate the differnance between 2 time

Posted: Mon May 25, 2009 7:18 am
by mahesh_php

Code: Select all

$diff_time=strtotime($time1)-strtotime($time2);
//$diff_time send time in seconds
echo $diff_time;
:roll:

Re: calculate the differnance between 2 time

Posted: Mon May 25, 2009 2:36 pm
by Darhazer
well, avoid using strtotime if it's not completely necessesary.

What's the problem here? You have the difference in seconds...

Code: Select all

 
$resullt = $result / 60; // in minutes
$result = $result / 60; // the above result, in hours
$result = $result / 24; // in days
Maybe you need a function, that outputs '1 Day, 12 hours, 12 minutes and 3 seconds' for example?

Re: calculate the differnance between 2 time

Posted: Tue May 26, 2009 10:43 am
by Benjamin
Locked due to lack of effort from the op.