From c7b4376e109378e347d70642170f865a0c57ac8d Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Tue, 9 Sep 2025 22:49:32 -0700 Subject: [PATCH] Forgot to commit the profiles timestamp thing --- incl/util.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/incl/util.php b/incl/util.php index 2601fa0..99667a4 100644 --- a/incl/util.php +++ b/incl/util.php @@ -103,4 +103,15 @@ function uuidv4() { $data[6] = chr((ord($data[6]) & 0x0f) | 0x40); $data[8] = chr((ord($data[8]) & 0x3f) | 0x80); return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); +} + +function genTimestamp($time) { + $time = time() - $time; + $time = ($time < 1) ? 1 : $time; + $tokens = array (31536000 => 'year', 2592000 => 'month', 604800 => 'week', 86400 => 'day', 3600 => 'hour', 60 => 'minute', 1 => 'second'); + foreach($tokens as $unit => $text) { + if($time < $unit) continue; + $numberOfUnits = floor($time / $unit); + return $numberOfUnits . ' ' . $text . (($numberOfUnits > 1) ? 's' : ''); + } } \ No newline at end of file