Format returning date format on Symfony2 FOSRestBundle

岁酱吖の 提交于 2019-12-11 12:01:52

问题


Is there any way to change the returning date format on a Webservice built with FOSRestBundle in Symfony2?

For example, this is my actual return:

{"id":9,"nome":"Guilherme","rg":"0000000000","cpf":"000.000.000-00","nascimento":"1989-06-24T00:00:00+0200","genero":"M"}

I want to change to this:

{"id":9,"nome":"Guilherme","rg":"0000000000","cpf":"000.000.000-00","nascimento":"1989-06-24","genero":"M"}

Thanks.


回答1:


It's just to add this annotation to the property:

@Type("DateTime<'Y-m-d'>")

See more: http://jmsyst.com/libs/serializer/master/reference/annotations#type



来源:https://stackoverflow.com/questions/29552966/format-returning-date-format-on-symfony2-fosrestbundle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!