X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FUtils.php;h=d6e066102b62a61baf96c4ad5cecd947725a11ac;hb=81bd104daa26204b8deffcd2d0723d234c9514a6;hp=5c077450e3a65016f55b0ede559dad4552b47e2b;hpb=b64d83cd2b60b6851741787f8ce2ae2c93092841;p=github%2Fshaarli%2FShaarli.git diff --git a/application/Utils.php b/application/Utils.php index 5c077450..d6e06610 100644 --- a/application/Utils.php +++ b/application/Utils.php @@ -321,24 +321,26 @@ function normalize_spaces($string) * otherwise default format '%c' will be returned. * * @param DateTime $date to format. + * @param bool $time Displays time if true. * @param bool $intl Use international format if true. * * @return bool|string Formatted date, or false if the input is invalid. */ -function format_date($date, $intl = true) +function format_date($date, $time = true, $intl = true) { if (! $date instanceof DateTime) { return false; } if (! $intl || ! class_exists('IntlDateFormatter')) { - return strftime('%c', $date->getTimestamp()); + $format = $time ? '%c' : '%x'; + return strftime($format, $date->getTimestamp()); } $formatter = new IntlDateFormatter( setlocale(LC_TIME, 0), IntlDateFormatter::LONG, - IntlDateFormatter::LONG + $time ? IntlDateFormatter::LONG : IntlDateFormatter::NONE ); return $formatter->format($date);