Try this one.
in this example I've pulled out the information into the var $date.
$date["a"]; to show it as predefined in the function.
$date["d or h or m or s"]; to pull out the day, hour, minute, second part individually.
<?php
function calcDuration ($duration) {
$output["d"] = floor(($duration / (606024)));
$output["h"] = ($duration / (60*60)) % 24;
$output["m"] = ($duration / 60) % 60;
$output["s"] = $duration % 60;
if ($output["d"] != 0) {
$output["a"] = $output["d"] . " days " . $output["h"] . " hrs " . $output["m"] . " mins " . $output["s"] . " secs";
}
elseif (($output["d"] == 0) && ($output["h"] != 0)) {
$output["a"] = $output["h"] . " hrs " . $output["m"] . " mins " . $output["s"] . " secs";
}
elseif (($output["d"] == 0) && ($output["h"] == 0) && ($output["m"] != 0)) {
$output["a"] = $output["m"] . " mins " . $output["s"] . " secs";
}
elseif (($output["d"] == 0) && ($output["h"] == 0) && ($output["m"] == 0)) {
$output["a"] = $output["s"] . " secs";
}
return $output;
}
$date = calcDuration(878872);
echo $date["a"];
?>