aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-03-28 20:40:14 +0200
committerArthurHoaro <arthur@hoa.ro>2017-03-28 20:43:30 +0200
commit81bd104daa26204b8deffcd2d0723d234c9514a6 (patch)
tree78caf8953e049376a4b33cb3810c4fc7dd56704f /application
parentb64d83cd2b60b6851741787f8ce2ae2c93092841 (diff)
downloadShaarli-81bd104daa26204b8deffcd2d0723d234c9514a6.tar.gz
Shaarli-81bd104daa26204b8deffcd2d0723d234c9514a6.tar.zst
Shaarli-81bd104daa26204b8deffcd2d0723d234c9514a6.zip
Theme: use format_date function for daily date
Diffstat (limited to 'application')
-rw-r--r--application/Utils.php8
1 files changed, 5 insertions, 3 deletions
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)
321 * otherwise default format '%c' will be returned. 321 * otherwise default format '%c' will be returned.
322 * 322 *
323 * @param DateTime $date to format. 323 * @param DateTime $date to format.
324 * @param bool $time Displays time if true.
324 * @param bool $intl Use international format if true. 325 * @param bool $intl Use international format if true.
325 * 326 *
326 * @return bool|string Formatted date, or false if the input is invalid. 327 * @return bool|string Formatted date, or false if the input is invalid.
327 */ 328 */
328function format_date($date, $intl = true) 329function format_date($date, $time = true, $intl = true)
329{ 330{
330 if (! $date instanceof DateTime) { 331 if (! $date instanceof DateTime) {
331 return false; 332 return false;
332 } 333 }
333 334
334 if (! $intl || ! class_exists('IntlDateFormatter')) { 335 if (! $intl || ! class_exists('IntlDateFormatter')) {
335 return strftime('%c', $date->getTimestamp()); 336 $format = $time ? '%c' : '%x';
337 return strftime($format, $date->getTimestamp());
336 } 338 }
337 339
338 $formatter = new IntlDateFormatter( 340 $formatter = new IntlDateFormatter(
339 setlocale(LC_TIME, 0), 341 setlocale(LC_TIME, 0),
340 IntlDateFormatter::LONG, 342 IntlDateFormatter::LONG,
341 IntlDateFormatter::LONG 343 $time ? IntlDateFormatter::LONG : IntlDateFormatter::NONE
342 ); 344 );
343 345
344 return $formatter->format($date); 346 return $formatter->format($date);