Page 1 of 1

Duration between two times - how do you calculate?

Posted: Fri Aug 17, 2012 9:31 am
by simonmlewis

Code: Select all

echo date("H:i", strtotime($row->timestart)); 
      echo " til ";
      echo date("H:i", strtotime($row->timeend)); 
      
      $v =  strtotime($row->timeend) - strtotime($row->timestart);
      echo " (Duration: ";
      echo date("h", $v);
      echo "hrs ";
      echo date("i", $v);
      echo "mins)";
This is bizarre.
$row->timestart is 19:00:00
$row->timeend is 21:00:00

Yet the result from the above on a LIVE server shows 7 hours.
Result from my local machine shows 3 hours.
If I change the LIVE one to 19:30 timeend, it says 3hrs 30 mins.

How the heck is that possible??

Re: Duration between two times - how do you calculate?

Posted: Fri Aug 17, 2012 11:23 am
by MindOverBody
In which format are timestart and timeend variables?