nice
All checks were successful
Build and push / Pulling repo on server (push) Successful in 2s

This commit is contained in:
2023-11-26 11:01:19 +01:00
parent 95837394a9
commit 26ec6de1e3
3 changed files with 36 additions and 3 deletions

View File

@ -322,4 +322,34 @@ function template($templatefile,$variables=[])
ob_end_clean();
return $pagecontent;
}
}
function printRelativeTime($timestamp1, $timestamp2)
{
$diff = abs($timestamp2 - $timestamp1);
$intervals = array(
'year' => 31536000,
'month' => 2592000,
'week' => 604800,
'day' => 86400,
'hour' => 3600,
'minute' => 60,
'second' => 1
);
$output = '';
foreach ($intervals as $interval => $seconds) {
$count = floor($diff / $seconds);
if ($count > 0) {
$output .= $count . ' ' . ($count === 1 ? $interval : $interval . 's') . ', ';
$diff -= $count * $seconds;
}
}
$output = rtrim($output, ', ');
return $output;
}