Reputation: 77
I have this code to take date from database and to fill with it an input field in powermail:
termin = TEXT
termin.stdWrap.dataWrap = DB:tx_seminars_seminars:{GP:tx_seminars_pi1|uid}:begin_date
termin.stdWrap.outerWrap = {|}
termin.insertData = 1
termin.htmlSpecialChars = 1
Value from field begin_date is displayed in powermail form, but i need to dispay it in human readable format (in DB it`s unix time) My problem is to fromat tstamp to %d %m %y
How to format it?
Upvotes: 0
Views: 2827
Reputation: 114
Here is the best solution to add the date as like times ago format:
Render the fluid section as below:
<f:render section="timeAgo" arguments="{posted:'{posting.datePosted}'}" />
Fluid section:
<f:section name="timeAgo">
<f:variable name="now" value="{f:format.date(date: 'now',format:'%s')}" />
<f:variable name="posted" value="{f:format.date(date:'{posted}',format:'%s')}" />
<f:variable name="diff" value="{now - posted}" />
<f:if condition="{diff} < 60">
<f:then>Now</f:then>
<f:else if="{diff} < 3600">
<f:format.number decimals="0">{diff / 60}</f:format.number> minute ago
</f:else>
<f:else if="{diff} < 86400">
<f:format.number decimals="0">{diff / 3600}</f:format.number> hours ago
</f:else>
<f:else if="{diff} < 604800">
<f:format.number decimals="0">{diff / 86400}</f:format.number> days ago
</f:else>
<f:else if="{diff} < 2419200">
<f:format.number decimals="0">{diff / 604800}</f:format.number> weeks ago
</f:else>
<f:else if="{diff} < 29030400">
<f:format.number decimals="0">{diff / 2419200}</f:format.number> months ago
</f:else>
<f:else>{f:format.date(date: '{posted}',format:'%d %B, %Y')}</f:else>
</f:if>
</f:section>
And it's done just pass your correct variable object at arguments="{posted:'{posting.datePosted}'}".
Thank you!
Upvotes: 0
Reputation: 2761
stdWrap
has a date attribute.
#Example where a timestamp is imported:
test.value.field = tstamp
test.value.date = d.m.Y H:i:s
http://wiki.typo3.org/TSref/stdWrap#date
EDIT:
Please note, that TEXT
is an instance of stdWrap
. You don't need to modify stdWrap for that simple wrapping. Adding {} there will modify the timstamp so that date is unable to get the right value.
Upvotes: 2