mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 02:44:53 +00:00
Expanded timeAgo function to incoude time ahead, added this functionality to client overview
This commit is contained in:
@@ -681,12 +681,16 @@ function sanitizeForEmail($data) {
|
||||
|
||||
function timeAgo($datetime) {
|
||||
$time = strtotime($datetime);
|
||||
$difference = time() - $time;
|
||||
$difference = $time - time(); // Changed to handle future dates
|
||||
|
||||
if ($difference < 1) {
|
||||
return 'just now';
|
||||
if ($difference == 0) {
|
||||
return 'right now';
|
||||
}
|
||||
$timeRules = array (
|
||||
|
||||
$isFuture = $difference > 0; // Check if the date is in the future
|
||||
$difference = abs($difference); // Absolute value for calculation
|
||||
|
||||
$timeRules = array(
|
||||
31536000 => 'year',
|
||||
2592000 => 'month',
|
||||
604800 => 'week',
|
||||
@@ -700,7 +704,8 @@ function timeAgo($datetime) {
|
||||
$div = $difference / $secs;
|
||||
if ($div >= 1) {
|
||||
$t = round($div);
|
||||
return $t . ' ' . $str . ($t > 1 ? 's' : '') . ' ago';
|
||||
$timeStr = $t . ' ' . $str . ($t > 1 ? 's' : '');
|
||||
return $isFuture ? 'in ' . $timeStr : $timeStr . ' ago';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user