[1, 'second'], 'm' => [60, 'minute'], 'h' => [60 * 60, 'hour'], 'd' => [60 * 60 * 24, 'day'], 'y' => [60 * 60 * 24 * 365, 'year'], ]; $effectiveTimeUnit = $timeUnit; if ($timeUnit == '') { $effectiveTimeUnit = 's'; for ($i = 0; $i < count($calcNum); $i++) { if ($clean <= $calcNum[$i][1]) { $effectiveTimeUnit = $calcNum[$i][0]; $i = count($calcNum); } } } $timeDifference = floor($clean / $calc[$effectiveTimeUnit][0]); $textSuffix = ''; if ($autoSuffix == true && ($currentTimestamp == time())) { if ($raw < 0) { $textSuffix = ' from now'; } else { $textSuffix = ' ago'; } } if ($referenceTimestamp != 0) { if ($timeDifference == 1) { return $timeDifference . ' ' . $calc[$effectiveTimeUnit][1] . ' ' . $textSuffix; } return $timeDifference . ' ' . $calc[$effectiveTimeUnit][1] . 's ' . $textSuffix; } return '(no reference timestamp was provided).'; } }