From e07fb9ce505763b4cc8f4193718c0628e5781a98 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Mon, 15 Jan 2024 22:59:39 -0500 Subject: [PATCH] Expanded timeAgo function to incoude time ahead, added this functionality to client overview --- client_overview.php | 15 ++++++++++----- functions.php | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/client_overview.php b/client_overview.php index 6f7fc1c4..2e1dd0ff 100644 --- a/client_overview.php +++ b/client_overview.php @@ -180,12 +180,13 @@ $sql_asset_retire = mysqli_query( $domain_id = intval($row['domain_id']); $domain_name = nullable_htmlentities($row['domain_name']); $domain_expire = nullable_htmlentities($row['domain_expire']); + $domain_expire_human = timeAgo($row['domain_expire']); ?>

- -- + --

- -- + --

@@ -216,12 +218,13 @@ $sql_asset_retire = mysqli_query( $asset_id = intval($row['asset_id']); $asset_name = nullable_htmlentities($row['asset_name']); $asset_install_date = nullable_htmlentities($row['asset_install_date']); + $asset_install_date_human = timeAgo($row['asset_install_date']); ?>

- -- + --

- -- + --

- + 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'; } } }