Elgg  Version 4.3
friendlytime.php
Go to the documentation of this file.
1 <?php
13 use Elgg\Values;
14 
16 $time_updated = elgg_extract('time_updated', $vars);
18 
19 try {
20  $date = Values::normalizeTime($time);
21  if (!empty($time_updated)) {
22  $date_updated = Values::normalizeTime($time_updated);
23  }
24 } catch (DataFormatException $e) {
25  return;
26 }
27 
28 $default_friendly_time_number_of_days = elgg_get_config('friendly_time_number_of_days');
30 
31 if (strtotime("-{$friendly_time_number_of_days}days") < $date->getTimestamp()) {
32  $output = elgg_get_friendly_time($date->getTimestamp());
33 } else {
34  $output = $date->formatLocale(elgg_echo('friendlytime:date_format:short'));
35 }
36 
37 $title = $date->formatLocale(elgg_echo('friendlytime:date_format'));
38 
39 if ($date_updated && ($date_updated->getTimestamp() > $date->getTimestamp() + 60)) {
40  $output = elgg_echo('friendlytime:updated', [$output]);
41  $title = elgg_echo('friendlytime:updated:title', [$title, $date_updated->formatLocale(elgg_echo('friendlytime:date_format'))]);
42 }
43 
45  'title' => elgg_extract('title', $vars, $title),
46  'datetime' => $date->format('c'),
47 ];
48 
Saves user notification settings.
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
if($date_updated &&($date_updated->getTimestamp() > $date->getTimestamp()+60)) $attributes
$time
$time_updated
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:135
$date_updated
$title
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:547
$friendly_time_number_of_days
elgg_get_friendly_time($time, $current_time=null)
Formats a UNIX timestamp in a friendly way (eg "less than a minute ago")
Definition: output.php:216
An exception thrown when there is a problem in the format of some data.
if(!empty($time_updated)) catch(DataFormatException $e) $default_friendly_time_number_of_days
elgg echo
Translates a string.
Definition: deprecated.js:530
$vars['head']
Definition: html.php:24
$output
Definition: download.php:9
elgg_get_config($name, $default=null)
Get an Elgg configuration value.