Skip to content

Instantly share code, notes, and snippets.

@saksmt
Created September 5, 2014 07:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saksmt/3c464f863d2129177f3f to your computer and use it in GitHub Desktop.
Save saksmt/3c464f863d2129177f3f to your computer and use it in GitHub Desktop.
Variable definition? I don't need it...
private function calculateDuration($startTime)
{
$currTime = time();
$diff = $currTime - $startTime;
if ($diff >= 3600) {
// hours
$difference = $diff/3600;
$difference = round($difference,0);
if ($difference>1) { $extra="s"; }
$difference = $difference." hour".$extra."";
}
elseif ($diff < 3600) {
// hours
$difference = $diff/60;
$difference = round($difference,0);
if ($difference>1) { $extra="s"; }
$difference = $difference." min".$extra."";
}
$duration = $difference;
return $duration;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment