We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Can't get Behaviors to Work

I'm trying to implement the Timestampable behavior in my model using the example given in the documentation https://docs.phalcon.io/en/latest/reference/models.html#timestampable

But the example doesn't work. Anytime you use a closure as an arguement I get an error stating:

Catchable fatal error: Object of class Closure could not be converted to string in file at line number...

Any Ideas?

I think you will have to return it as string, i had same problem when tryed using closure example

Return what as a string? If I set the entire closure as a string it will work, but I will get a pretty weird response when I dump out the model object after it sets the value.

This is what I get when using the example.

create_time: "f00000042014-04-21T17:28:14+00:00302820144() { $21pm30UTC302804UTC = 4UTC1 Monpm30UTC302804UTC(4UTC1 Monpm30UTCUTC2804UTC020144UTC("E000000Mon, 21 Apr 2014 17:28:14 +00002014pUTC/st3020142014-04-21T17:28:14+00:00k052014Monday04")); Mon, 21 Apr 2014 17:28:14 +0000UTC30000000Mon, 21 Apr 2014 17:28:14 +00004 $21pm30UTC302804UTC->f2014Mon, 21 Apr 2014 17:28:14 +000004pm30("2014-04-21 17:28:14+00:00"); }"

i meant date format as string (Y-m-d H:i:s etc.), as in other example ... about closure i just know i gave up because i had problems