0

TYPO3 v11, PHP 8.0.8.

The following line in a fluid template:

<f:format.date format="%d. %B %y">{newsItem.datetime}</f:format.date>

delivers an empty string for every date in march.

I got the following debug outputs for a date in february:

DateTimeprototypeobject (2023-02-06T13:15:46+01:00, 1675685746)
' 06. Februar 23 ' (28 chars)

So the locale is correct and i get local dates in german.

But for dates in march i get the following debug output:

DateTimeprototypeobject (2023-03-07T16:00:08+01:00, 1678201208)
'' (25 chars)

The Datetime-Object is correct but the formatted string is empty.

Any ideas whats going on here? Thanks!

lisardo
  • 1,322
  • 16
  • 31
  • 1
    Seems to be a locale issue. As the German "March" has an umlaut, the system can't output due to locale or even utf-8 settings. – Thomas Löffler May 25 '23 at 08:45

1 Answers1

1

two possible solutions are already registered at SO:
German Umlauts in strftime date-formatting - correct utf-8 encoding?
Character encoding within German date created with strftime()

  1. make sure your locale is set with UTF8 encoding:
    setlocale(LC_TIME, "de_DE.UTF-8");
    (make sure the the name is written correct and compare it with the list of available locals with this shell command: locale -a | grep -i "de_de")

regarding TYPO3: set $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale']

  1. encode the result for further usage:
$date_german = strftime("%e. %B %Y", $timestamp_start);
$date_german = utf8_encode($date_german);

maybe with an additional ViewHelper???

Bernd Wilke πφ
  • 10,390
  • 1
  • 19
  • 38
  • the problem was indeed a wrong locale - which i not realized because it was only a typo: de_DE.utf-8 instead of de_DE.utf8 ... both exists and only one is correct. – lisardo Jul 10 '23 at 11:01
  • the name of the current locale can vary from system to system. I added a hint to get the currently active locals on a system. – Bernd Wilke πφ Jul 17 '23 at 12:02