TimestampBehavior Expression value

I am using TimestampBehavior set column created_at to new Expression(‘NOW()’).

return [


                'class' => TimestampBehavior::className(),

                'value' => new Expression('NOW()'),



After creating a new record, the restful api reutrn ‘created_at’ as


    "created_at": {

        "expression": "NOW()",

        "params": []



But actually I need the value to be ‘2015-02-03 10:10:10’.

How can I get it?

I create a new CreateAction and refresh the model.

class CreateAction extends \yii\rest\CreateAction


    public function run()


        $model = parent::run();


        return $model;



The method refresh has to reload the data from database.

I am not sure it’s the best way.

something like this?

'value' => function () { return \Yii::$app->formatter->asDatetime('now', 'dd-MM-yyyy hh:mm:ss'); }

Why not give that possibility to the database if it supports?