Reputation: 462
I'm trying to calculate the age based on a timestamp, eg. 761353200 in Typoscript. The timestamp 761353200 is February 16, 1994.
I'm sending the data from a Fluid-Template to Typoscript:
<f:cObject typoscriptObjectPath="lib.userAge">
<f:format.date format="U">{user.dateOfBirth}</f:format.date>
</f:cObject>
{user.dateOfBirth} equals 761353200 in this case.
The calculation in Typoscript looks like this:
lib.userAge = TEXT
lib.userAge.current = 1
lib.userAge.age = 1
The problem: The returned value is 23, but should be 22.
I tried it with another timestamp (556408800) and this returns 29, as it should. This is absolutely confusing to me.
Does anybody has an idea why the calculation behaves like that?
Upvotes: 0
Views: 392
Reputation: 356
I think the conversion makes it too imprecise. Why don't you use just a fluid viewhelper without using typoscript? So the code is better to maintain. I found this ViewHelper. Can you copy and integrate it in your extension/template? https://searchcode.com/codesearch/view/39628010/
Upvotes: 3