Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.