[TYPO3-mvc] Editing dates
Henjo Hoeksma
me at henjohoeksma.nl
Fri Sep 17 16:35:52 CEST 2010
On 2010-09-17 16:19:31 +0200, Henjo Hoeksma said:
> 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?
Found it myself. It appeared to be a different format for the datetime
picker I had chosen... So the values weren't matching ;-)
Thanks,
Henjo
More information about the TYPO3-project-typo3v4mvc
mailing list