Formatting date returned in REST

Hi.

I’m trying to return UTC date with my REST API, to have it like that: “2015-04-25 16:01:59Z”. Is there any easy way to configure Yii to use Formatter when returning data with REST?

Thanks

Not sure if I understood your question correct?

But sure, there are plenty ways to format data in any application.

Setup Data Formatter:

http://www.yiiframework.com/doc-2.0/guide-output-formatter.html

Or a afterfind function in model:




public function afterFind(){

	parent::afterFind(); 


	// Format attributes like ever you want to receive them

	$this->created_at = date('d.m.Y - H:i:s', $this->created_at);

	$this->updated_at = date('d.m.Y - H:i:s', $this->updated_at);


	// You could also format the data with the yii data formatter here... 

	

}



Hope this helps?

Regards

I was looking for some way that I can do that with config for whole dates across all models in my API. After checking Yii2 code I know already that it’s not possible, and your solution is easiest to do, even if that means to change that across whole models.

Thank you :)