function display($r) { $json = json_decode(file_get_contents($r), true); if (isset($json["outtime"])) { $ft = date("c", $json["outtime"]); return "<a href={$r}><time dateTime={$ft}>{$ft}</time> lasting " . getNiceDuration($json["outtime"] - $json["intime"]) . "</a>"; } else { $ft = date("c", $json["intime"]); return "<a href={$r}>" . e($json["name"]) . " on duty since <time dateTime={$ft}>{$ft}</time> with mobile number " . e($json["tel"]) . "</a>"; } }
include './1_lookups.php'; include './2_DepartmentsPeopleCategories.php'; include './3_Clients.php'; include './4_Tickets.php'; function getNiceDuration($durationInSeconds) { $duration = ''; $days = floor($durationInSeconds / 86400); $durationInSeconds -= $days * 86400; $hours = floor($durationInSeconds / 3600); $durationInSeconds -= $hours * 3600; $minutes = floor($durationInSeconds / 60); $seconds = $durationInSeconds - $minutes * 60; if ($days > 0) { $duration .= $days . ' days'; } if ($hours > 0) { $duration .= ' ' . $hours . ' hours'; } if ($minutes > 0) { $duration .= ' ' . $minutes . ' minutes'; } if ($seconds > 0) { $duration .= ' ' . $seconds . ' seconds'; } return $duration; } $endTime = time(); $duration = $endTime - $startTime; echo getNiceDuration($duration);