N
N
nepster-web2014-04-10 16:01:12
Yii
nepster-web, 2014-04-10 16:01:12

Yii2, how to correctly write getters for fields in a model?

Tell me, please, how to do the following thing correctly, for example, we have a date after it, and it must be brought to a human-understandable form before output, how to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri Morozov, 2014-04-10
@nepster-web

public function getCreated { return нужная_функция_форматирования($this->created_at); }
...
echo $model->created;

The only problem is that, despite the seeming convenience of model getters, formatting fields is, generally speaking, the task of the display layer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question