From 81bd104daa26204b8deffcd2d0723d234c9514a6 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Tue, 28 Mar 2017 20:40:14 +0200 Subject: Theme: use format_date function for daily date --- application/Utils.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'application/Utils.php') 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); -- cgit v1.2.3