【问题标题】:TYPO3 Fluid check date formatTYPO3 流体检查日期格式
【发布时间】:2017-11-21 08:37:38
【问题描述】:

我得到一个特定的日期格式 (Y-m-d) 并想检查是否只有年份以流体形式给出。

基本上你在后端输入“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>

但它不起作用。我怎样才能做到这一点?

【问题讨论】:

  • 这个字段在TCA中是如何配置的?这是纯文本字段还是有效日期(实际日期时间)或整数字段?

标签: typo3 fluid


【解决方案1】:

如果这只是一个纯文本字段(字符串),您可以使用v:format.substring helper 并比较字符串的最后一部分:

<f:if condition="{v:format.substring(content:history.date, start:4, length:7)} == '-00-00'">

【讨论】:

    【解决方案2】:

    我认为您在日期内联表示法中缺少 ,。试试这个。

    <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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-10
      • 2020-12-25
      • 1970-01-01
      • 2014-12-17
      • 1970-01-01
      • 2015-04-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多