28 if (preg_match(
'/(?<!\\|%)[ntLBueIPZcr]/', $dateFormat)) {
35 'd' =>
'%d',
'D' =>
'%a',
'j' =>
'%e',
'l' =>
'%A',
'N' =>
'%u',
'w' =>
'%w',
'z' =>
'%j',
39 'F' =>
'%B',
'm' =>
'%m',
'M' =>
'%b',
41 'o' =>
'%G',
'Y' =>
'%Y',
'y' =>
'%y',
43 'a' =>
'%P',
'A' =>
'%p',
'g' =>
'%l',
'h' =>
'%I',
'H' =>
'%H',
'i' =>
'%M',
's' =>
'%S',
45 'O' =>
'%z',
'T' =>
'%Z',
55 return strtr((
string) $dateFormat, $caracs);
69 if ($correct_format ===
false) {
70 elgg_log(
"Unable to convert date format: '{$format}', using non-locale version",
'INFO');
71 return $this->format($format);
75 $current_locale =
elgg()->locale->setLocaleFromLanguageKey(LC_TIME,
$language);
77 $result = strftime($correct_format, $this->getTimestamp());
80 elgg()->locale->setLocale(LC_TIME, $current_locale);
83 elgg_log(
"Unable to generate locale representation for format: '{$correct_format}', using non-locale version",
'INFO');
84 return $this->format($format);
formatLocale(string $format, string $language=null)
Format the date using strftime() which supports locale output.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
dateFormatToStrftime(string $dateFormat)
Convert a date format to a strftime format.