JMS serializer yml date and time format

I have a Restore API based on Symfony 2.7 Framework with FOSRestBundle and JMSSerializerBundle . I look at yml reference and annotations .

I decided to determine how each object in my model is serialized using yml .

I saw that we can serialize a Datetime object in a specific format:

 @JMS\Type("DateTime<'dm-Y'>") 

But I do not know the correct syntax used with the yml definition , I tried:

 my_field: expose: true type: datetime format: 'dmY' 

AND

 my_field: expose: true type: datetime<'dm-Y'> 

I do not want to use Annotations because I have many yaml files.

But the field is not serialized ...

Can anybody help me?

+5
source share
1 answer

I consider this an answer if it helps more people:

 my_field: expose: true type: DateTime<'dm-Y'> 
+10
source

Source: https://habr.com/ru/post/1262575/


All Articles