Typo3视图助手日期在三月份的每个日期都提供空字符串。

huangapple go评论51阅读模式
英文:

typo3 viewhelper date delivers empty string for every date in march

问题

TYPO3 v11,PHP 8.0.8。

在一个 Fluid 模板中的以下行:

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

对于三月的每个日期都返回空字符串。

我对二月的某个日期获得了以下调试输出:

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

因此,区域设置是正确的,我获得了德语的本地日期。

但是对于三月的日期,我得到了以下调试输出:

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

Datetime-Object 是正确的,但格式化的字符串为空。

对此有什么想法吗?谢谢!

英文:

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!

答案1

得分: 1

two possible solutions are already registered at SO:
https://stackoverflow.com/questions/12680716/german-umlauts-in-strftime-date-formatting-correct-utf-8-encoding
https://stackoverflow.com/questions/54335144/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 name is written correctly and compare it with the list of available locales 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???

英文:

two possible solutions are already registered at SO:
https://stackoverflow.com/questions/12680716/german-umlauts-in-strftime-date-formatting-correct-utf-8-encoding
https://stackoverflow.com/questions/54335144/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???

huangapple
  • 本文由 发表于 2023年5月25日 16:38:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76330345.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定