YII2 Restful post和TimestampBehavior

I'm trying to use TimestampBehavior in my Restful API created Yii2, but when I create a new entity using the POST endpoint, the return data is quite strange.

{
  "i18_id": 3,
  "language": "es",
  "text": "un test de traducción",
  "created_at": {
    "expression": "NOW()",
    "params": [ ]
  },
  "updated_at": {
    "expression": "NOW()",
    "params": [ ]
  },
  "id": 2
}

When I GET the entity later everything looks fine.

Here is how I've declared the Behavior in my model:

public function behaviors()
{
    return [
        'timestamp' => [
            'class' => 'yii\behaviors\TimestampBehavior',
            'attributes' => [
                ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
                ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
            ],
            'value' => new Expression('NOW()'),
        ],
    ];
}

I guess you have added the Entry in your test and return the model just added.

I guess a simple $model->refresh(); will fill the values.

See official docs here.

I'm using this value:

'value' => function() { return date('U'); },

So finally I've found a good solution thanks to @BHoft suggestion.

Mainly I'm using the rest ActiveController and my api needs to return the date after creation using a date format, so the date('U') doesn't work in my case because it doesn't return the date on the right format.

What I've done is that I've added an afterSave to my model.

public function afterSave ($insert, $changedAttributes)
{
    if ($insert)
        $this->refresh();
}