JMSSerializer how to change handler for specific type one time

440 Views Asked by At

I'm using jmsserializerbundle with the following:

jms_serializer:
    enable_short_alias:   true
    handlers:
        datetime:
            default_format:       'Y-m-d\TH:i:sO'
            default_timezone:     America/Bogota
            cdata:                true

now when serializer found a DateTime class converts to '2014-11-11T15:10:22-0500' format, the whole application works with that. but i need in only one point use the 'Y-m-d' format ¿how i can achieve it?

1

There are 1 best solutions below

0
On

On your one time entry, you could do the following

/**
 * @Type("DateTime<'Y-m-d'>")
 */
private $updatedAt;

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