英文:
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
- 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']
- 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
- 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']
- 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???
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论