How to implement calculated properties in Doctrine ORM?

There is a date field in a table but when retrieving data you need to including seconds back (time() - $timestamp). If understand correctly, you need to entice new property to have, and in it refer to the date. How to do it correctly?

To push through postLoad ?
August 19th 19 at 23:43
2 answers
August 19th 19 at 23:45
I think that it is the task of doctrine to form you an idea of the date. you can search and write custom extension for tviga that will generate you the desired entry (perhaps with translations) from the DateTime object

if it is a SPA, I would have given to the client timestamp and there brought to the desired appearance using the same moment.js
August 19th 19 at 23:47
I would create a getter and added this field to the serializer.
I made an additional getter in the entity(getLast), but he does not give the desired value - only the default value (1). Even if I write `returt 5` - the output is still 1 - timmothy_Bedn commented on August 19th 19 at 23:50
Like rise of the machines. - Juwan.Hirthe commented on August 19th 19 at 23:53

Find more questions by tags Doctrine ORM