3600 * 24 * 3) { if (date('Y') === date('Y', $timestamp)) { return date('d.m.', $timestamp); } return date('m.Y', $timestamp); } return $prefix . self::showHourMin($duration); } public static function timeUntil($timestamp) { return self::duration($timestamp - time()); } protected static function formatForUnits($value, & $units, $base) { $sign = ''; if ($value < 0) { $value = abs($value); $sign = '-'; } $pow = floor(log($value, $base)); $result = $value / pow($base, $pow); // 1034.23 looks better than 1.03, but 2.03 is fine: if ($pow > 0 && $result < 2) { $pow--; $result = $value / pow($base, $pow); } return sprintf( '%s%0.2f %s', $sign, $result, $units[$pow] ); } }