[TYPO3-mvc] Extbase/Fluid with DateTime objects
Thomas "Thasmo" Deinhamer
thasmo at gmail.com
Tue Dec 22 22:26:11 CET 2009
Ah, you got me rolling:
<f:if condition="{f:format.date(date: '{DateTime}', format: 'U')}">
Output: {f:format.date(date: '{DateTime}', format: 'd.m.Y')}
</f:if>
The format 'U' returns the timestamp, so the if viewhelper returns
true if an integer is larger than zero. Using this, you can even
skip the empty 'then' viewhelper.
Hm, should't there be a better way of checking a valid DateTime object?
The bad thing is, that the timestamp of 0 (zero) is a valid timestamp?!
Is there another approach of 'disabling' the display of a
date or datetime field coming from the backend, which was NOT set?
Thanks,
Thomas
Joerg Schoppet schrieb:
> Hi,
>
> I solved it this way:
>
> <f:if condition="{f:format.date(date: object.dateTime, format: 'U')} == 0">
> <f:then>
> </f:then>
> <f:else>
> <f:format.date format="Y-m-d">{object.dateTime}</f:format.date>
> </f:else>
> </f:if>
>
>
> Joerg
>
>
>
> Thomas "Thasmo" Deinhamer schrieb:
>> How can I check if a DateTime Object has a valid value?
More information about the TYPO3-project-typo3v4mvc
mailing list