today I tried to use the EEL Date.format() function to convert a DateTime object to a readable string.
This causes the output “01.01.1970” for every value I try to convert. I checked everything but the syntax doesn’t seem wrong to me.
this.item is defined, I just trimmed off the rest of the Fusion file to simplify it for here.
The problem consists even if I put in a static value, therefore I’m a bit confused why it happens.
But I can say for sure that It’s not an error with variables or their values.
What exactly do you mean by static value? Did you try a unix timestamp or Date.now() instead of q(this.item).property('deadline')?
BTW: Just to be sure: this.item is only defined if it is set within the Neos.Fusion:Tag in this scenario. Are you sure it’s defined in the right place? This gets easily confused, that’s why I’m asking
Meanwhile the code changed a bit but still with same results.
I’ll add the whole file below to make everything clear (i hope).
With static I meant other DateTime Objects, not declared by variable. I haven’t tried Date.now() to be honest because I gave up after some time and changed it to content = ${Date.dayOfMonth(q(item).property('deadline'))+'.'+Date.month(q(item).property('deadline'))+'.'+Date.year(q(item).property('deadline'))}
which actually works fine but then why the .format() not?
Hi @mschmidt, it seems that you’re right, that Date.format() doesn’t work like expected.
If you pass in a timestamp like ${Date.format(Date.now().timestamp, 'd.m.Y')}
then it works fine. But if you pass in a string it doesn’t work. In this case it seems that in the format-Method of the DateHelper-Class the string is not processed properly.
As mentioned in my previous reply I’ve changed it to the three EEL functions for day, month and year therefore I’ll leave it like this to keep it working.
But I hope this will be reviewed sometime.
Thanks to @wbehncke and @Martelinho for your participation in my problem
Hi @mschmidt just wanted to ask if you made a bug report? Couldn’t find something about it on the given github pages. I think on give-and-take basis it would be fair to help improving the system. If you don’t write a report just let me know. Then I would do this by citing your posts.
Hi @mschmidt, just looked for a bug report and couldn’t find one. But as I never did one on github and even don’t have an account for it it also might be that I just can’t find it.Is this problem already reported or maybe even solved?
Where you have to replace <format>with the format string of the deadline property (or pass null if you want PHP to try to determine the right format for you)
As described I’m not used to the reporting processes and tools and therefore can not be sure that it is not already reported. So first an answer of Maximilan would make the situation and todos clearer.
Hi Bastian, sorry, right at the moment I have to do very urgent tax purposes. So a quick answer is ok but no time left for more. In addition as you can read above I didn’t have that problem. I just read this post and at that moment invested some time to analyze the core problem. Afterwards I just wanted to make sure that the problem and the infos will be reported to the community as a pay back. I already offered to do the report but Maximilian said to do so. If noone does I will do that as soon as I have the time fpr that which is not now, sorry. But maybe it’s already done, I don’t know. Maximilian can tell that without big effort.