diff options
Diffstat (limited to 'inc/util.inc.php')
| -rw-r--r-- | inc/util.inc.php | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/inc/util.inc.php b/inc/util.inc.php index ed0b40ae..91232f46 100644 --- a/inc/util.inc.php +++ b/inc/util.inc.php @@ -335,16 +335,17 @@ class Util * The format depends on how far the timestamp lies in the past. * * @param int $ts unix timestamp + * @param bool $useSmartAbbreviation use words like "yesterday", leave out year, if applicable * @return string human-readable representation */ - public static function prettyTime(int $ts): string + public static function prettyTime(int $ts, bool $useSmartAbbreviation = true): string { settype($ts, 'int'); if ($ts === 0) return '???'; static $TODAY = false, $ETODAY = false, $YESTERDAY = false, $YEARCUTOFF = false; if (!$ETODAY) $ETODAY = strtotime('today 23:59:59'); - if ($ts > $ETODAY) // TODO: Do we need strings for future too? + if (!$useSmartAbbreviation || $ts > $ETODAY) // TODO: Do we need strings for future too? return date('d.m.Y H:i', $ts); if (!$TODAY) $TODAY = strtotime('today 0:00'); if ($ts >= $TODAY) |
