TYPO3 流体检查日期格式
TYPO3 Fluid check date format
我得到一个特定的日期格式 (Y-m-d) 并想检查是否只有年份以 fluid 形式给出。
基本上你在后端输入“2017-00-00”,输出应该是“2017”。
我想到了这样的事情:
<f:if condition="{f:format.date(date: 'Y-00-00' format: 'Y-m-d')}">
<f:then>
<f:format.date format="%d.">{history.date}</f:format.date>
</f:then>
<f:else>
<f:format.date format="%d. %B %Y">{history.date}</f:format.date>
</f:else>
</f:if>
但是这是行不通的。我怎样才能做到这一点?
如果这只是一个纯文本字段(字符串),您可以使用 v:format.substring helper 并比较字符串的最后部分:
<f:if condition="{v:format.substring(content:history.date, start:4, length:7)} == '-00-00'">
我认为您在日期内联表示法中缺少 ,
。试试这个。
<f:if condition="{f:format.date(date: 'Y-00-00', format: 'Y-m-d')}">
<f:then>
<f:format.date format="%d.">{history.date}</f:format.date>
</f:then>
<f:else>
<f:format.date format="%d. %B %Y">{history.date}</f:format.date>
</f:else>
</f:if>
我得到一个特定的日期格式 (Y-m-d) 并想检查是否只有年份以 fluid 形式给出。
基本上你在后端输入“2017-00-00”,输出应该是“2017”。
我想到了这样的事情:
<f:if condition="{f:format.date(date: 'Y-00-00' format: 'Y-m-d')}">
<f:then>
<f:format.date format="%d.">{history.date}</f:format.date>
</f:then>
<f:else>
<f:format.date format="%d. %B %Y">{history.date}</f:format.date>
</f:else>
</f:if>
但是这是行不通的。我怎样才能做到这一点?
如果这只是一个纯文本字段(字符串),您可以使用 v:format.substring helper 并比较字符串的最后部分:
<f:if condition="{v:format.substring(content:history.date, start:4, length:7)} == '-00-00'">
我认为您在日期内联表示法中缺少 ,
。试试这个。
<f:if condition="{f:format.date(date: 'Y-00-00', format: 'Y-m-d')}">
<f:then>
<f:format.date format="%d.">{history.date}</f:format.date>
</f:then>
<f:else>
<f:format.date format="%d. %B %Y">{history.date}</f:format.date>
</f:else>
</f:if>